This tutorial aims to help readers complete the construction and use of the SpringCloud microservice system to help readers understand the concept of microservices in practice.
As the first part of the tutorial, we first build the registration and discovery service.
Build the registration and service discovery service projects
Build a simple Spring Boot project in IDEA, name the groupId: cn.com.hohistar.tutorial, and the artifactId: springcloud-discovery-server, and then replace the content in the original pom.xml file with the following:
1 |
|
Custom startup class
Add @EnableEurekaServer annotation to the original startup class. The modified code is as follows:
1 |
|
Add configuration file
Rename the file application.properties in src/main/resouces to: application.yml. And fill in the following content:
1 | server: |
Start the app
Start the application in IDEA, and then open it in the browser
1 | http://localhost:8761 |
You can see that the registration service has been started.
Next
In next step, we will practice how to change an existing Spring Boot application into a registerable service.