Şuayb's BlogŞuayb's Blog
Home
Categories
Games
MediumAboutContact
Language
Theme
    1. Blog
    2. Programming
    3. Spring Boot Eureka Server

Spring Boot Eureka Server

PublishedFebruary 23, 2025
UpdatedFebruary 24, 2025
Reading time3 min read
JavaKotlinSpring BootSpring CloudEureka ServerMicroservice
XLinkedInFacebook
Spring Boot Eureka Server

Loading likes...

Spring Boot Eureka Server is a service registry that enables service discovery in a microservices architecture. It allows microservices to register themselves and discover other services dynamically. This guide will walk you through setting up and configuring a Spring Boot Eureka Server.


Last updatedFebruary 24, 2025

Total viewsLoading hits...

Previous articleSpring Boot Config ServerNext articleSpring Boot Circuit Breaker
Şuayb Şimşek

Written by

Şuayb Şimşek

Backend-focused fullstack developer sharing practical notes on Spring Boot, security, microservices, and cloud-native architecture.

Expertise

  • Spring Boot
  • Go
  • Microservices
  • Next.js
  • Cloud Native

Connect

GitHubLinkedInMedium

Related posts

Spring Boot Circuit Breaker
Programming

Spring Boot Circuit Breaker

Learn how to implement Circuit Breaker in Spring Boot applications for resilient microservices.

March 13, 20253 min read
JavaKotlinSpring BootSpring CloudCircuit BreakerMicroservice
Spring Boot Config Server
Programming

Spring Boot Config Server

Learn how to use Spring Boot Config Server to centralize and manage application configurations efficiently.

February 22, 20253 min read
JavaKotlinSpring BootSpring CloudConfig ServerMicroservice
Spring Boot Kubernetes Integration
Programming

Spring Boot Kubernetes Integration

Learn how to deploy Spring Boot applications on Kubernetes for scalable, containerized microservices.

February 21, 20253 min read
JavaKotlinSpring BootKubernetesMicroserviceContainerization

About

Articles on Spring Boot, microservices, security, and more.

ContactStart here

Latest posts

  • Captain Tsubasa 2: World Fighters
  • Captain Tsubasa: Rise of New Champions
  • Spring Boot Configuration Properties
  • Spring Boot GraphQL JWE Authentication
  • Spring Boot JWE Authentication with JPA

Top topics

JavaKotlinSpring BootJWEJWTMicroservice

Subscribe

Get practical backend + fullstack notes when new articles are published.

Social

© 2024-2026 Şuayb's Blog. All rights reserved.

🌟 Why Use Eureka Server?

In this section, we clarify Why Use Eureka Server? and summarize the key points you will apply in implementation.

  • Service Discovery: Automatically register and discover microservices.
  • Load Balancing: Enables client-side load balancing with Ribbon.
  • Failover Support: Services can find alternative instances if one fails.
  • Scalability: Easily scale microservices without manual configuration.
  • Spring Cloud Integration: Works seamlessly with Spring Boot applications.

📋 Prerequisites

Ensure you have the following:

  • ☕ Java Development Kit (JDK) 17+
  • 📦 Maven or Gradle installed

🛠️ Step 1: Add Dependencies

In this section, we clarify Step 1: Add Dependencies and summarize the key points you will apply in implementation.

Maven:

XMLpom.xml
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>

Gradle:

GROOVYbuild.gradle
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server'

🛠️ Step 2: Create the Eureka Server Application


🛠️ Step 3: Configure the Eureka Server

Create an application.yml file for Eureka Server configuration.

YAMLapplication.yml
server:
  port: 8761
spring:
  application:
    name: eureka-server
eureka:
  client:
    register-with-eureka: false
    fetch-registry: false
  server:
    wait-time-in-ms-when-sync-empty: 5

Note: The Eureka Server does not register itself.


▶️ Running the Eureka Server

Start the Eureka Server application:

BASH
./mvnw spring-boot:run

or using Gradle:

BASH
gradle bootRun

Access the Eureka Server dashboard:

BASH
http://localhost:8761/

🛠️ Step 4: Register a Client Application

In this section, we clarify Step 4: Register a Client Application and summarize the key points you will apply in implementation.

Add Dependencies

Add the Eureka Client starter first so this application can register with the server and participate in service discovery.

Maven:

XMLpom.xml
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

Gradle:

GROOVYbuild.gradle
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'

Client Application Configuration

In the client's application.yml, add the following:

YAMLapplication.yml
spring:
  application:
    name: eureka-client
eureka:
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka/

Client Application Code

The sample below provides a minimal client implementation so you can validate the server integration end to end.


▶️ Running the Client Application

Run the Eureka Client application:

BASH
./mvnw spring-boot:run

or using Gradle:

BASH
gradle bootRun

Check if the client has registered with Eureka Server by visiting:

BASH
http://localhost:8761/

🏁 Conclusion

You now have a practical Spring Boot Eureka Server implementation with a clear, production-friendly Spring Boot structure. As a next step, adapt configuration and tests to your own domain, then validate behavior under realistic traffic and failure scenarios.

JAVAEurekaServerApplication.java
package com.example.eurekaserver;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(EurekaServerApplication.class, args);
    }
}
KOTLINEurekaServerApplication.kt
package com.example.eurekaserver

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer

@SpringBootApplication
@EnableEurekaServer
class EurekaServerApplication

fun main(args: Array<String>) {
    runApplication<EurekaServerApplication>(*args)
}
JAVAEurekaClientApplication.java
package com.example.eurekaclient;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
@RequestMapping("/client")
public class EurekaClientApplication {

    @GetMapping
    public String getClientMessage() {
        return "Hello from Eureka Client!";
    }

    public static void main(String[] args) {
        SpringApplication.run(EurekaClientApplication.class, args);
    }
}
KOTLINEurekaClientApplication.kt
package com.example.eurekaclient

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@SpringBootApplication
@RestController
@RequestMapping("/client")
class EurekaClientApplication {

    @GetMapping
    fun getClientMessage(): String {
        return "Hello from Eureka Client!"
    }
}

fun main(args: Array<String>) {
    runApplication<EurekaClientApplication>(*args)
}