依赖
<!--SpringCloud整合Zookeeper,对应注解:@EnableDiscoveryClient--><dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId> <exclusions> <!--先排除自带的zookeeper3.5.3--> <exclusion> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> </exclusion> </exclusions></dependency><!--添加zookeeper3.4.14版本--><dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> <version>3.4.14</version></dependency>
配置
server: port: 8081spring: application: name: zk-member cloud: zookeeper: connect-string: 127.0.0.1:2181
应用
@EnableDiscoveryClient
@SpringBootApplication
public class MyApp {
public static void main(String[] args) {
SpringApplication.run(MyApp.class, args);
}
}