Spring Cloud Eureka - SirajChaudhary/comprehensive-example-on-microservices-using-spring-boot-with-spring-cloud GitHub Wiki

Eureka is the Netflix Service Discovery Server and Client.

Spring Cloud Eureka Server

Step1: Add spring cloud netflix eureka server dependency in pom.xml in eureka-server microservice.

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

Step2: Add spring cloud netflix eureka server properties in application.yaml in eureka-server microservice.

# EUREKA SERVER PROPERTIES
eureka:
  client:
    register-with-eureka: 'false'
    fetch-registry: 'false'

Step3: Mark main class with following annotation in eureka-server microservice.

@EnableEurekaServer

Spring Cloud Eureka Clients

When a eureka client registers with eureka server, it provides meta-data about itself — such as host (IP address), port, health indicator URL, home page, and other details.

Step1: Add spring cloud netflix eureka client dependency in pom.xml in every microservice.

<!-- spring cloud starter eureka client -->
<dependency>
	<groupId>org.springframework.cloud</groupId>
	<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
	<version>${spring-cloud.version}</version>
</dependency>

Step2: Add spring cloud netflix eureka client properties in application.yaml in every microservice.

# EUREKA SERVER URL
eureka:
  client:
    service:
      url:
        defaultZone: 'http://localhost:8761/eureka

Step3: Mark main class with following annotation in every microservice.

@EnableEurekaClient
⚠️ **GitHub.com Fallback** ⚠️