How To Start The Spring Eureka Server

Posted By : Abhilasha Saxena | 30-Apr-2021

Java java microservices Server Spring boot

Loading...

Do we need to download any Eureka server just like we download Tomcat or any other server?

The answer is NO.

Follow below steps to start spring Eureka Server:

Step 1:

To create a Eureka server we just need to create a spring boot application. And how do we create a spring boot application with spring initializr

If we download this project then it will be just a spring boot application but what makes it a Eureka server if we add a dependency called Eureka server.

There is another Eureka dependency called Eureka Discovery, that's the client.

Spring boot comes with two Eureka dependencies: whatever application you want as Eureka server you use Eureka server dependency and whatever application you want to do the discovering or to publish and tell the Eureka server I am here you use the Eureka client dependency.

Now we'll download/Generate this project as a startup or Discovery server.

Step 2:

Open the downloaded project in any IDE as a Maven Project and set up the SDK.

This is how your pom.xml should look like with the dependencies already added.

Step 3:

Add @EnableEurekaServer annotation to the main application class and below properties to application.properties file.

eureka.client.register-with-eureka=false

eureka.client.fetch-registry=false

We add these properties so that Eureka does not register with itself. As every Eureka Server is also a Eureka Client. When the server runs it not only provides the registry, it also tries to register with other Eureka Servers. Because you can have multiple instances of Eureka Servers and they can register with each other so that if one Server fails another server can still provide service.

So these two properties tell Eureka Server that you are the only server here, don't search for any other or don't act as a client.

Step 4:

Run your main class

You will see "Started Eureka Server" in your logs, Eureka's default port is 8761

Below is the UI which spring Eureka comes with default mentioning the system status, current time, how long it is up for.

There is a section which says Instances currently registered with Eureka. Right now it says No instances available, as no instances are currently registered with this eureka server.

So we need to create microservices and add eureka clients, only then those microservices have the functionality to tell Eureka Server they exist.

As the Eureka Server is in ready mode for accepting request, Now you can create your microservices to make those request


We are an ERP development company that provides end-to-end software solutions to enhance business productivity. Our custom ERP application development services enable businesses to streamline their inbound/outbound operations with advanced problem-solving capabilities. For more information, contact us at [email protected].