Skip to content

Spring Cloud Eureka

SirajChaudhary edited this page Sep 25, 2022 · 12 revisions

Spring Cloud Eureka Server

Step1: Add spring cloud 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 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

@EnableEurekaServer

Spring Cloud Eureka Clients

Step1: Add spring cloud eureka client dependency in pom.xml in every microservice and api-gateway 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 eureka client properties in application.yaml

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

Step3: Mark main class with following annotation

@EnableEurekaClient

Clone this wiki locally