ServiceComb Java Chassis supports generating provider-service API implicitly. When the service is started, an API is automatically generated and registered to the service center.
When you develop a microservice in transparent RPC mode, the code does not show how you want to define an API, and all generated APIs are POST methods, The input parameters of all the methods will be packaged as a class and transferred as body parameters. Therefore, if you develop providers using implicit APIs, you are advised to choose Spring MVC or JAX-RS mode to obtain complete RESTful statements.
For detail information please refer to Doc
Start the ServiceComb/Service Center
microservice.yaml
fileservicecomb: service: registry: address: http://127.0.0.1:30100 #service center address
Start the codefirst-provider service
Start provider service via maven
Compile the source code, and use mvn exec
to execute the main class CodeFirstProviderMain
.
mvn clean install cd codefirst-sample/codefirst-provider/ mvn exec:java -Dexec.mainClass="org.apache.servicecomb.samples.codefirst.provider.CodeFirstProviderMain"
Start provider service via gradle
Compile the source code, and use mvn exec
to execute the main class CodeFirstProviderMain
.
cd codefirst-sample/codefirst-provider/
Start provider service via IDE
Import the project by InteliJ IDEA or Eclipse, then find main
function CodeFirstProviderMain
of provider service and RUN
it like any other Java program.
Start the codefirst-consumer service
mvn clean install cd codefirst-sample/codefirst-consumer/ mvn exec:java -Dexec.mainClass="org.apache.servicecomb.samples.codefirst.consumer.CodeFirstConsumerMain"
Start consumer service via maven
Just like how to start codefirst-provider service. But the main class of codefirst-consumer service is CodeFirstConsumerMain
.
mvn exec:java -Dexec.mainClass="org.apache.servicecomb.samples.codefirst.consumer.CodeFirstConsumerMain"
Start consumer service via gradle
gradle clean run
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: