Hackforge Academy

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

🚀 Learn Spring Boot with real-world projects

💡 Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
⚛️

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community