引入依赖

  1. <dependency>
  2. <groupId>org.springframework.cloud</groupId>
  3. <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
  4. </dependency>

修改配置文件

  1. server:
  2. port: 9006
  3. spring:
  4. application:
  5. name: zk-consumer
  6. cloud:
  7. zookeeper:
  8. connect-string: yuluocloud.com:2181 # zookeeper服务器地址

添加注解

  1. @EnableDiscoveryClient
  2. @SpringBootApplication
  3. public class ZkConsumerApplication {
  4. public static void main(String[] args) {
  5. SpringApplication.run(ZkConsumerApplication.class, args);
  6. }
  7. }