1、下载:https://blog.csdn.net/luoyuxin12/article/details/89391044?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control

(1)YML

  1. Spring:
  2. application:
  3. name: cloud-provider-payment
  4. cloud:
  5. zookeeper:
  6. connect-string:192.168.111.144:2181

(2)POM

  1. <!---SpringBoot整合zookeeper客户端-->
  2. <dependency>
  3. <groupId>org.springframework.cloud</groupId>
  4. <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
  5. <!--先排出自带的zookeeper3.5.3-->
  6. <exclusions>
  7. <exclusion>
  8. <groupId>org.apache.zookeeper</groupId>
  9. <artifactId>zookeeper</artifactId>
  10. </exclusion>
  11. </exclusions>
  12. </dependency>
  13. <!--添加zookeeper3.4.9版本-->
  14. <dependency>
  15. <groupId>org.apache.zookeeper</groupId>
  16. <artifactId>zookeeper</artifactId>
  17. <version>3.4.9</version>
  18. </dependency>

(3)主启动

  1. @SpringBootApplicaiton
  2. @EnableDiscoveryClient
  3. public class PaymentMain8004{
  4. }

image.png