天天看點

Spring Cloud Consul啟動時相關服務不能注冊到Consul注冊中心

(網上說法不一)

如下親測........(大部分是因為項目引用的Consul相關jar包與Consul注冊中心不比對)

本例使用的Consul是1.5.2版本

[[email protected] ~]# 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
           

能成功注冊的服務的日志如下:

Spring Cloud Consul啟動時相關服務不能注冊到Consul注冊中心