注册中心 Zookeeper
1.pom引入依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>
2.修改yml配置
spring: application: name: cloud-order-service cloud: zookeeper: connect-string: localhost:2181
3.主启动类上添加 @EnableDiscoveryClient
@SpringBootApplication @EnableDiscoveryClient public class OrderZkMain80 { public static void main(String[] args) { SpringApplication.run(OrderZkMain80.class, args); } }
4.依赖冲突问题
注意 spring-cloud-starter-zookeeper-discovery包中包含 org.apache.zookeeper.discovery,可能会版本冲突,使用exclusions标签进行排除
作者:[一柒微笑]

浙公网安备 33010602011771号