Registering microservices with Eureka

To register any microservice with the Eureka Name server, we would need to add the dependency on Eureka Starter project. The following dependency needs to be added to the pom.xml file of Microservice A:

    <dependency>      <groupId>org.springframework.cloud</groupId>      <artifactId>spring-cloud-starter-eureka</artifactId>    </dependency>

The next step is to add EnableDiscoveryClient to the SpringBootApplication classes. An example of MicroserviceAApplication is shown here:

    @SpringBootApplication    @EnableDiscoveryClient    public class MicroserviceAApplication {
Spring Cloud Commons hosts the common classes used in different Spring Cloud implementations. A good example is the @EnableDiscoveryClient annotation. Different ...

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.