SpringCloud微服务-Zookeeper注册中心

SpringCloud微服务-Zookeeper注册中心,第1张

SpringCloud微服务-Zookeeper注册中心

前言: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);
    }
}

查看日志,发现服务注册成功了

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5665307.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存