
- Hazelcast 教程
- Hazelcast - 首頁
- Hazelcast - 簡介
- Hazelcast - 設定
- Hazelcast - 第一個應用程式
- Hazelcast - 配置
- 設定多節點例項
- Hazelcast - 資料結構
- Hazelcast - 客戶端
- Hazelcast - 序列化
- Hazelcast 高階
- Hazelcast - Spring 整合
- Hazelcast - 監控
- Map Reduce 和聚合
- Hazelcast - 集合偵聽器
- 常見陷阱和效能提示
- Hazelcast 實用資源
- Hazelcast - 快速指南
- Hazelcast - 實用資源
- Hazelcast - 討論
Hazelcast - 設定
Hazelcast 要求 Java 1.6 或更高版本。Hazelcast 也可與 .NET、C++ 或其他基於 JVM 的語言(如 Scala 和 Clojure)配合使用。然而,對於本教程,我們將使用 Java 8.
在繼續之前,以下是我們將用於本教程的專案設定。
hazelcast/ ├── com.example.demo/ │ ├── SingleInstanceHazelcastExample.java │ ├── MultiInstanceHazelcastExample.java │ ├── Server.java │ └── .... ├── pom.xml ├── target/ ├── hazelcast.xml ├── hazelcast-multicast.xml ├── ...
現在,我們只需建立包(即 hazelcast 目錄內的 com.example.demo)。然後,只需切換到該目錄。我們將在即將到來的部分中檢視其他檔案。
安裝 Hazelcast
安裝 Hazelcast 只需將 JAR 檔案新增到構建檔案中。基於你分別使用 Maven 還是 Gradle 的 POM 檔案或 build.gradle。
如果你使用的是 Gradle,只需將以下內容新增到 build.gradle 檔案中即可 −
dependencies { compile "com.hazelcast:hazelcast:3.12.12” }
教程的 POM
我們將為我們的教程使用以下 POM −
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>1.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> <name>demo</name> <description>Demo project for Hazelcast</description> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>com.hazelcast</groupId> <artifactId>hazelcast</artifactId> <version>3.12.12</version> </dependency> </dependencies> <!-- Below build plugin is not needed for Hazelcast, it is being used only to created a shaded JAR so that --> <!-- using the output i.e. the JAR becomes simple for testing snippets in the tutorial--> <build> <plugins> <plugin> <!-- Create a shaded JAR and specify the entry point class--> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.2.4</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
廣告