Questions Management – Register services with Eureka Server using Eureka Discovery of Spring Cloud Netflix

Check out the full series of Questions Management tutorial here.

Our Questions Management application currently has 8 services including 3 Core Service, 2 Composite Service, and 3 API Service. To register them with Eureka Server, as I mentioned in the tutorial Register services with Eureka Server using Eureka Client, with Spring Cloud Netflix, the first thing we need to do is to add the Eureka Discovery dependency into all service projects. You open the pom.xml file for each service project and add the new Eureka Discovery dependency as follows:

Here, I also added the Spring Boot Actuator dependency to enable the service information in the Questions Management application. You can find out more about the Spring Boot Actuator here.

Next, we will declare the @EnableEurekaClient annotation to each main class of each service project:

  • ApiCategoryServiceApplication of the api-category-service project
  • ApiOptionServiceApplication of the api-option-service project
  • ApiQuestionServiceApplication of the api-question-service project
  • CompositeOptionServiceApplication of composite-option-service project
  • CompositeQuestionServiceApplication of the composite-question-service project
  • CoreCategoryServiceApplication of the core-category-service project
  • CoreOptionServiceApplication of core-option-service project
  • CoreQuestionServiceApplication of the core-question-service project

Next, in the file of each service project, you add the information of the Eureka Server that we will register for each service.

The last step is to name each service to distinguish them from the Eureka Server.

I’ll take the name of each service and add a new<service_name> property in the file.

For example, for the API Category Service, the value of the project is as follows:

OK, that’s it. Please try to start all project services, server and then visit http://localhost:8761/ to see the results!

Myself as follows:

Questions Management - Register services with Eureka Server using Eureka Discovery of Spring Cloud Netflix

Chia sẽ bài viết này ...Share on Facebook
0Tweet about this on Twitter
Share on LinkedIn

Add Comment