引入依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
</dependency>
修改配置文件
server:
port: 9006
spring:
application:
name: zk-consumer
cloud:
zookeeper:
connect-string: yuluocloud.com:2181 # zookeeper服务器地址
添加注解
@EnableDiscoveryClient
@SpringBootApplication
public class ZkConsumerApplication {
public static void main(String[] args) {
SpringApplication.run(ZkConsumerApplication.class, args);
}
}