Building Microservices with Spring Boot – Spring Cloud Netflix Eureka Registry
- June 19, 2019
“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.
• Java 8
• Spring Boot
• Spring Cloud
• Eureka Service Registry / Eureka Service Client
• Mongo DB
• Zuul API Gateway
• JWT Based Authentication Layer
• Spring Security
“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 use Spring 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.
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,
to clients application.properties.
Then the client service will register with service registry when starts.