I am trying to register a sample SpringBoot service to consul with the help of SpringCloud, but without success when using latest versions.
Versions with success :
- SpringBoot : 2.0.0.RELEASE
- Cloud : Finchley.RELEASE
- Consul : 1.4.0
Versions without success :
- SpringBoot : 2.1.1.RELEASE
- Cloud : Finchley.RELEASE
- Consul : 1.4.0
My pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>server</artifactId>
<groupId>com.ote.test</groupId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<!--version>2.0.0.RELEASE</version-->
<version>2.1.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerVersion>${java.version}</compilerVersion>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I start consul with the command : consul agent -dev
My service provides "/health" endpoint and declare @EnableDiscoveryClient
My configuration is (application.yml or bootstrap.yml, same result):
spring:
application:
name: server
cloud:
consul:
host: localhost
port: 8500
discovery:
tags: test
enabled: true
instanceId: ${spring.application.name}:${vcap.application.instance_id:${spring.application.instance_id:${random.value}}}
healthCheckPath: /health
healthCheckInterval: 5s
When I start the service with SpringBoot 2.0.0.RELEASE, it works well. When I start the exactly same service with SpringBoot 2.1.1.RELEASE, the service is not registered to consul (and cannot be discovered by any client)
What is wrong or missing ?