Get started
Install Java development environment
-
Install Git, details can refer to Git Installing Guide.
-
Install JDK 1.8, details can refer to JDK Installing Guide.
-
Install Maven 3.x, details can refer to Maven Installing Guide.
-
Download ServiceComb-Samples.
git clone https://github.com/apache/servicecomb-samples.git cd servicecomb-samples/java-chassis-samples/bmi mvn clean install
Run Service Center
Service Center enables capabilities of service registration and service discovery in ServiceComb. It can run inside docker.
docker pull servicecomb/service-center
docker run -d -p 30100:30100 servicecomb/service-center:latest
Reference to Install of ServiceCenter to learn deploying Service Center as a local binary.
Create your first microservice application
Let's start the journey of microservice with a simple Body Mass Index(BMI) application. The BMI is an attempt to quantify the amount of tissue mass in an individual. This application contains two separate microservices:
-
BMI calculator service:A microservice provides calculation of BMI.
-
Web service:A microservice provides both user interface and gateway service.
The workflow of the application is shown as follows:
Note that the dotted lines indicate the process of service registration and discovery.
Run microservice application
-
Enter BMI codes directory.
cd servicecomb-samples/java-chassis-samples/bmi
Note: In windows development environment, the docker runs inside the virtual machine. The IP address of Service Center needs to be modified as the virtual machine's IP address. Modify the 2 configuration files [calculator|webapp]/src/main/resources/microservice.yaml, changed http://127.0.0.1:30100 to http://192.168.99.100:30100 , where 192.168.99.100 is the virtual machine's IP address.
-
Run microservices.
cd calculator; mvn spring-boot:run cd webapp; mvn spring-boot:run
-
Verify the application. Visit http://localhost:8889 in browser. Then input your height and weight to verify.
What’s next
- Learn how to develop microservice application in minutes.