Spring Cloud Consul启动时相关服务不能注册到Consul注册中心

(网上说法不一)

如下亲测........(大部分是因为项目引用的Consul相关jar包与Consul注册中心不匹配)

本例使用的Consul是1.5.2版本

[root@centoshadoop4 ~]# consul version
Consul v1.5.2
Protocol 2 spoken by default, understands 2 to 3 (agent will automatically use protocol >2 when speaking to compatible agents)
 

问题描述: 项目能正常启动,但相关服务不能注册到Consul注册中心

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
<!--<version>2.1.2.RELEASE</version>-->  --不能注册 
<!--<version>2.1.1.RELEASE</version>-->  --不能注册 
<!--<version> 2.1.3.RELEASE</version>-->  --不能注册  
<!--<version>2.1.0.RELEASE</version>-->--能注册   
<version>2.0.9.RELEASE</version>  --能注册 
<relativePath/>
</parent>

springcloud版本为:

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-dependencies</artifactId>
  <version>Finchley.RELEASE</version>
  <type>pom</type>
  <scope>import</scope>
</dependency>
spring-cloud-starter-consul-discovery.2.0.0.RELEASE spring-cloud-starter-consul-config.2.0.0.RELEASE

能成功注册的服务的日志如下:

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值