Building Microservices with Spring Boot - Spring Cloud Netflix Eureka Registry

Follow the step-by-step development process to build a microservices project using Spring Boot with a few microservices and Eureka service registry.

"Microservices" is one of the biggest topics which have gained in popularity in recent days. Here I'll describe the step-by-step development process, which we could follow to build microservices project using spring boot with few microservices and Eureka service registry.


Technology Stack :

  • Java 8
  • Spring Boot
  • Spring Cloud
  • Eureka Service Registry / Eureka Service Client
  • Mongo DB
  • Zuul API Gateway
  • JWT Based Authentication Layer
  • Spring Security
  • Gradle
  • Docker

Build Eureka Service Registry

"Service Registry", The heart of a microservices project, Because It's the central service where all the services and route providers are connecting. We could build a service registry using simple Spring Boot project with adding Spring Cloud Netflix Eureka service registry functions.

You can useSpring Initializr to generate Basic Spring Boot Project.

It could be done by adding 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server' library to Spring Boot application and adding @EnableEurekaServer on Main class.


Build Services and Register with Eureka Service Registry

Now we've service registry which is configured and running correctly, Then we can focus on building services and register those services with the service registry. Then we can focus on building services and register those services with the service registry. To do that, we've to add 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client' library to Spring Boot application and add @EnableEurekaClient in the main class. These two steps will make ready your microservice to register with Eureka server. But how microservice know where to connect ? That can be done using configurations.

Let's say our application registry is running on http://localhost:3000 then, we can introduce application registry to client by adding,

eureka.client.serviceUrl.defaultZone=http://localhost:3000/eureka

to clients application.properties.

Then the client service will register with service registry when starts.


Resources For Post

Full Detailed Description

Gitlab Public Repo For Sources