VOOZH about

URL: https://www.geeksforgeeks.org/advance-java/spring-boot-eureka-service-registry/

⇱ Getting Started with Spring Boot and Eureka Service Registry - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Getting Started with Spring Boot and Eureka Service Registry

Last Updated : 27 May, 2026

Eureka is a Service Registry provided by Netflix that helps microservices register and discover each other dynamically. Spring Boot and Eureka together make it easier to build scalable and distributed microservices applications.

  • Helps microservices communicate without hardcoding URLs.
  • Provides service discovery and client-side load balancing.

Some Important Concept

  • Microservices: An architectural style where applications are divided into small independent services. Each service performs a specific business task.
  • Eureka : A Netflix service registry used for service registration and discovery in microservices architecture.
  • Service Registry: A central directory that stores details of all available microservices and their network locations.
  • Service Discovery: A mechanism that helps services locate and communicate with other services dynamically.
  • Eureka Server: The main registry server that manages and monitors registered microservices.
  • Eureka Client: A microservice that registers itself with Eureka Server and discovers other services.
  • Instance Registration: The process where a microservice registers itself with Eureka during startup.
  • Instance Deregistration: The process of removing a service from Eureka when the service stops running.
  • Service Name: A unique name assigned to a microservice for identification and communication.
  • Load Balancing: Distributes requests among multiple service instances to improve performance and availability.

Step-by-step implementation

Below are the steps for both Eureka Server and Eureka Client to start with Spring Boot and Eureka Service Registry.

Eureka-Server

Step 1: Create Spring Boot Project

Create a Spring Boot project using Spring Initializr.

Add Dependencies:

  • Spring Web
  • Eureka Server
  • Spring DevTools
  • Lombok

After creating the Spring project, the file structure resembles the image below.

👁 File Structure

Step 2: Configure application.properties

Open the application.properties file and put the below code for the server port and eureka server configuration to the project.

spring.application.name=eureka-server-config
server.port=9099
eureka.instance.prefer-ip-address=true
eureka.client.fetch-registry=true
eureka.client.register-with-eureka=true
eureka.client.service-url.defaultZone=http://localhost:9099/eureka


Step 3: Enable Eureka Server

In the main class, add the annotation @EnableEurekaServer to enable Eureka server functionality.


Step 4: Run the Eureka Server

Run the application as a Spring Boot application and it runs successful then it starts at port 9099.

👁 Eurekaserver Started

User-service(Eureka-Client)

Step 1: Create Spring Boot Project

Add Dependencies:

  • Spring Web
  • Eureka Discovery Client
  • Spring DevTools
  • Lombok

After creating the Spring project, the file structure resembles the image below.

👁 File Structure


Step 2: Configure application.properties

Open the application.properties file and put the below code for the server port and eureka client configuration to the project.

spring.application.name=user-service
server.port=8086
eureka.instance.prefer-ip-address=true
eureka.client.fetch-registry=true
eureka.client.register-with-eureka=true
eureka.client.service-url.defaultZone=http://localhost:9099/eureka


Step 3: Create Controller Class

Create the new Java class and it named as UserController. Go to src > org.example.userservice > UserController and put the below code.

Step 4: Enable Discovery Client

Open the main class and add the @EnableDiscoveryClient into it.

Step 5: Run the Client Application

Run the client application as a Spring Boot application and it runs successful then it starts at port 8086.

👁 Userlog Started


Eureka Dashboard

This dashboard provides the visibility into the microservices registered with Eureka Server and their status and the other relevant information.

👁 Eureka Dashboard

If we follow the above steps, we can successfully implement the Eureka Service Registry of the spring boot application. By the following these steps and principles, we can effectively build and manage the Microservices Architecture using the Spring Boot and Eureka Service Registry.

Comment
Article Tags:

Explore