RestTemplate
is a RESTful API provide by the Spring framework. ServiceComb provides the API for service calling. Users can call microservices using customized URL and RestTemplate
instance provided by ServiceComb regardless of the specific address of the service.
cse://microserviceName/path?querystring
.Start the ServiceComb/Service Center
microservice.yaml
fileservicecomb: service: registry: address: http://127.0.0.1:30100 #service center address
Start the springmvc-provider service
Start provider service by maven
Compile the source code, and use mvn exec
to execute the main class SpringmvcProviderMain
.
mvn clean install cd springmvc-sample/springmvc-provider/ mvn exec:java -Dexec.mainClass="org.apache.servicecomb.samples.springmvc.provider.SpringmvcProviderMain"
Start provider service by IDE
Import the project by InteliJ IDEA or Eclipse, then find main
function of provider service and RUN
it like any other Java Program.
Start the springmvc-consumer service
Just like how to start springmvc-provider service. But the main class of springmvc-consumer service is SpringmvcConsumerMain
.
cd springmvc-sample/springmvc-consumer/ mvn exec:java -Dexec.mainClass="org.apache.servicecomb.samples.springmvc.consumer.SpringmvcConsumerMain"
How to verify On the producer side, the output should contain the following stuffs if the producer starts up successfully:
On the consumer side, you can see the following outputs if the consumer can invoke the producer: