To be able to register a microservice instance in the Eureka server, we need to do the following:
Add a dependency to spring-cloud-starter-netflix-eureka-client in the build file, build.gradle:
Implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
Copy
When running tests on a single microservice, we don't want to depend on having the Eureka server up and running. Therefore, we will disable the use of Netflix Eureka in all Spring Boot tests, that is, JUnit tests annotated with @SpringBootTest. This can be done by adding the eureka.client.enabled property and setting it to false in the annotation, like so:
@SpringBootTest(webEnvironment=RANDOM_PORT, properties = {"eureka.client.enabled=false"})
Copy
Finally, add some configuration. Please go to the Setting up configuration for development use section, where we will go through the configuration for both the Eureka server and our microservices.