Spring MicroService registration with Eureka Server

Home / Spring MicroService registration with Eureka Server

In Last Post ( Eureka Server ) we have seen that how to create a Eureka Server. Now we learn how to register our microservices on Eureka Server, We register our microservice on Eureka because of we need a dashboard where we can check status of our all microservices. So for registering them on eureka we have to follow below steps.

  1. Create a project and add required dependency in your pom.xml file
  2. Enable your main class as a client using @EnableEurekaClient annotation.
  3. Define Eureka Server path in your application.properties file.

Follow above steps:

1- Add Below dependency in pom.xml



2- Enable Eureka Client using @EnableEurekaClient

package com.javadream;

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

public class MicroService1Application {

	public static void main(String[] args) {
		SpringApplication.run(MicroService1Application.class, args);


3- Define below lines in your application.properties file


Now run this application and check your Eureka Server You will get a instance of MICROSERVICE-1 on port 8081.

NOTE: Make Sure before running your microservice-1 application your eureka server is already running otherwise it will throw exception that no server found.

Complete Code On GitHub : Register MicroService Source Code

Help Others, Please Share

About Author

Leave a Reply

Your email address will not be published. Required fields are marked *