Spring Boot 3.2.0 Eureka Server & Client Integration

seyhmusaydogdu
3 min readDec 20, 2023

--

In this section, With the latest version of Spring Boot, 3.2.0, we will create the most used Eureka Server in microservice architecture and a sample application to connect to it. If you ready, let’s get started 🚀

Spring Boot Version: 3.2.0

Spring Cloud Version: 2023.0.0

Java Version: 21

Eureka Server Application

You can think of it as a structure that keeps a list of applications running on the platform. Each microservice application registers itself to Eureka Server. Eureka Server has a mechanism that periodically sends requests to applications and checks whether they are alive or not. If the previously registered application is not standing, it is automatically deleted from the list.

The contents of the pom.xml file are as follows.

The content of the application.yml file is as follows.

server.port: It is specified on which port the application will serve. The default port number for Eureka Server is 8761.

eureka.client.registerWithEureka: We set this property to false so that it does not register itself in the list. Because; Here it acts as a server, not a client.

eureka.client.fetchRegistry: This value is set to false because it will not retrieve the registered microservices list from anywhere. It will create and maintain this list itself.

Here, we use the EnableEurekaServer annotation to define the application that will run as an Eureka Server application.

Now, when we wake up the application and call the address http://localhost:8761/ a page like the one below should open.

Eureka Discovery Client Application

It is a sample microservice application that will register to Eureka Server.

The contents of the pom.xml file are as follows.

The content of the application.yml file is as follows.

eureka.client.serviceUrl.defaultZone: This information must be given to which Eureka Server address the application will connect to.

server.port: It is the port number information on which the application will run. Spring boot applications use 8080 by default. You can change it if you want.

spring.application.name: The name of the application. It is saved in the Eureka Server with the name you give.

Here, we use the EnableEurekaClient annotation to define the application that will run as a client application.

Now, when we wake up the application and call the address http://localhost:8761/, we can see that the application named eureka-client that we created in the list is registered to the Eureka Server.

You can access all codes of Eureka Server and Eureka Client projects from the address below.

Sign up to discover human stories that deepen your understanding of the world.

--

--

seyhmusaydogdu
seyhmusaydogdu

Written by seyhmusaydogdu

Senior Software Engineer @ Yapı Kredi Technology

No responses yet

Write a response