by BehindJava

How to startup and configure Eureka Discovery Service as a Eureka Server in Spring Boot

Home » microservices » How to startup and configure Eureka Discovery Service as a Eureka Server in Spring Boot

In this tutorial we are going to learn about Eureka Discovery service configuration in spring boot.

Firstly, generate a Spring Boot project using Spring Initializr as show in the below images and add the required dependencies i.e., Eureka client and Eureka server.


Once the project is generated. It is download as a ZIP file, UNZIP the project and import in your Spring Tool Suite and go through the dependencies related to the Eureka client and server. This may be bit confusing because we included both client and server, spring boot application can act both as client and server where we can configure it as a client or server depending the requirement.

So, to make our Spring Boot application work as a Eureka Discovery server we need add an annotation called @EnableEurekaServer in the main class as shown below.

Sample Code Snippet:

package com.example.UserDiscoveryService;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@EnableEurekaServerpublic class UserDiscoveryServiceApplication {

	public static void main(String[] args) {, args);


Now we need to add few configurations under src/main/resources in the as shown below.


Since Eureka server can be a client and server at the same time, so we need to specify these eureka.client.register-with-eureka, eureka.client.fetch-registry as false to prevent this application with Eureka to register as client and service-url.defaultZone is a fully qualified URL through which client applications communicate with the Eureka server.

Once all the above changes are done in your application, run the application as sprint boot app in Spring Tool Suite if console shows up any error remove the dependency related eureka client since we are making our application as server and hit the URL http://localhost:8010/ and a page will be displayed with many details as shown below.