tree: 669c0dca84af90d24618926aa141f0228499037a [path history] [tgz]
  1. dubbo-samples-spring-boot-consumer/
  2. dubbo-samples-spring-boot-interface/
  3. dubbo-samples-spring-boot-provider/
  4. case-configuration.yml
  5. case-version-sources.conf
  6. case-versions.conf
  7. pom.xml
  8. README.md
1-basic/dubbo-samples-spring-boot/README.md

Dubbo Spring Boot Example

This example shows how to use Dubbo Spring Boot Starter to develop Dubbo application. For the underlying RPC protocol, we are using triple and at the same time, we use java interface as the way to define service. It‘s a more convenient way to develop Dubbo application if there’s no cross-language communication requirement.

Please refer to

Modules

  • interface, provides Dubbo service definition
  • provider, implements Dubbo service
  • consumer, consumes Dubbo service

How to run

Start Nacos

This example replies on Nacos as service discovery registry center, so you need to run the Nacos server first, there are two ways to do so:

  1. Download Nacos binary and start it directly
  2. Start Nacos using docker

Install dependencies

Step into ‘dubbo-samples-spring-boot’ directory, run the following command:

$ mvn clean install

Start provider

Enter provider directory:

$ cd dubbo-samples-spring-boot-provider

then, run the following command to start provider:

$ mvn compile exec:java -Dexec.mainClass="org.apache.dubbo.springboot.demo.provider.ProviderApplication"

Run the following command to see server works as expected:

curl \
    --header "Content-Type: application/json" \
    --data '["Dubbo"]' \
    http://localhost:50052/org.apache.dubbo.springboot.demo.DemoService/sayHello/

Start consumer

Enter provider directory:

$ cd dubbo-samples-spring-boot-consumer

then, run the following command to start consumer:

$ mvn compile exec:java -Dexec.mainClass="org.apache.dubbo.springboot.demo.consumer.ConsumerApplication"