74. 安装 Zookeeper

有关如何安装 Zookeeper 的说明,请参阅installation documentation

Spring Cloud Zookeeper 在后台使用 Apache Curator。尽管 Zookeeper 开发团队仍将 Zookeeper 3.5.x 视为“测试版”,但现实是许多用户在 Producing 使用了它。但是,Zookeeper 3.4.x 也用于 Producing。在 Apache Curator 4.0 之前,两个版本的 Apache Curator 支持两种版本的 Zookeeper。从 Curator 4.0 开始,通过相同的 Curator 库支持两个版本的 Zookeeper。

如果要与版本 3.4 集成,则需要更改curator以及spring-cloud-zookeeper随附的 Zookeeper 依赖项。为此,只需排除该依赖关系并添加如下所示的 3.4.x 版本。

maven.

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-zookeeper-all</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.apache.zookeeper</groupId>
    <artifactId>zookeeper</artifactId>
    <version>3.4.12</version>
    <exclusions>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </exclusion>
    </exclusions>
</dependency>

gradle.

compile('org.springframework.cloud:spring-cloud-starter-zookeeper-all') {
  exclude group: 'org.apache.zookeeper', module: 'zookeeper'
}
compile('org.apache.zookeeper:zookeeper:3.4.12') {
  exclude group: 'org.slf4j', module: 'slf4j-log4j12'
}