In this series of previous article, we practiced how to build a registration and discovery service. Now, we are going to practice registering a business service.
In this experiment, we use an example built on Spring Boot to serve as a developed business segment. For example construction, please refer to Spring Boot 构建Rest服务实验手册(一)
To use the Spring Boot application as a registerable service of Spring Cloud, you only need to simply change the following three places in the project:
In the project’s pom.xml file:
- Change the version number of the project’s parent element spring-boot-starter-parent to: 2.0.5.RELEASE, the modified version is as follows:
- Add the following dependency libraries and dependency management items:
Add @EnableEurekaClient annotation to the startup class of Spring Boot application, the code is as follows:
Delete the test class in the test/java directory.
Add the following content in the project configuration file: application.yaml:
Start the application and visit the registration server to see if the current application has been registered:
In next step, we will practice a Gateway in Spring Cloud.