Category: spring_boot
Eureka Server in spring boot
Published on 22 Aug 2026
Explanation
A Eureka Server acts as a service registry in a Spring Cloud microservices architecture. Microservices register themselves with Eureka, and other services can discover them dynamically.
Code:
Client │ ▼ Eureka Server :8761 │ ├── USER-SERVICE :8081 ├── ORDER-SERVICE :8082 └── PAYMENT-SERVICE :8083
Explanation
Create a Spring Boot project for the Eureka Server. Add Spring Cloud Netflix Eureka Server dependency. The Eureka Server will normally run on port 8761.
Code:
Spring Initializr Project: Maven Language: Java Dependencies: - Spring Web - Eureka Server server.port=8761
Explanation
Enable the Eureka Server in the main Spring Boot application using the @EnableEurekaServer annotation.
Code:
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(
EurekaServerApplication.class,
args
);
}
}
Explanation
Configure the Eureka Server in application.properties. Since this application itself is the Eureka Server, it should not register itself as a client or try to fetch a registry from another Eureka Server.
Code:
spring.application.name=eureka-server server.port=8761 eureka.client.register-with-eureka=false eureka.client.fetch-registry=false
Explanation
Start the Spring Boot application and open the Eureka dashboard in a browser. The dashboard allows you to see registered microservices and their status.
Code:
Run: ./mvnw spring-boot:run Dashboard: http://localhost:8761 Initially: No registered services
Explanation
After creating the Eureka Server, the next step is to create Eureka Clients such as User Service and Order Service. These services register themselves with Eureka when they start.
Code:
Eureka Server
:8761
▲
register│
┌──────────────┴──────────────┐
│ │
User Service Order Service
:8081 :8082
Next:
Create Eureka Client