前言:zookeeper是一个分布式协调工具,可以实现注册中心功能,关闭Linux服务器防火墙后启动zookeeper服务器,zookeeper服务器取代Eureka服务器,zk作为服务注册中心
新建一个项目:cloud-provider-payment8004
pom依赖
org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-actuator org.springframework.cloud spring-cloud-starter-zookeeper-discovery org.springframework.boot spring-boot-devtools runtime true org.projectlombok lombok true org.springframework.boot spring-boot-starter-test test org.springframework.cloud spring-cloud-starter-zookeeper-discovery org.apache.zookeeper zookeeper org.apache.zookeeper zookeeper 3.4.6
yml配置
server:
port: 8004
spring:
application:
name: cloud-provider-payment
cloud:
zookeeper:
connect-string: 192.168.136.140:2181 #你的zookeeper服务
主启动类
@SpringBootApplication
@EnableDiscoveryClient
public class PaymentMain8004 {
public static void main(String[] args) {
SpringApplication.run(PaymentMain8004.class,args);
}
}
查看日志,发现服务注册成功了



