前言:zookeeper是一个分布式协调工具,可以实现注册中心功能,关闭Linux服务器防火墙后启动zookeeper服务器,zookeeper服务器取代Eureka服务器,zk作为服务注册中心
新建一个项目:cloud-provider-payment8004
pom依赖
org.springframework.boot spring-boot-starter-weborg.springframework.boot spring-boot-starter-actuatororg.springframework.cloud spring-cloud-starter-zookeeper-discoveryorg.springframework.boot spring-boot-devtoolsruntime true org.projectlombok lomboktrue org.springframework.boot spring-boot-starter-testtest org.springframework.cloud spring-cloud-starter-zookeeper-discoveryorg.apache.zookeeper zookeeperorg.apache.zookeeper zookeeper3.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); } }
查看日志,发现服务注册成功了
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)