项目作者: alibaba

项目描述 :
Dubbo Spring Boot Starter
高级语言: Java
项目地址: git://github.com/alibaba/dubbo-spring-boot-starter.git
创建时间: 2017-01-20T08:02:19Z
项目社区:https://github.com/alibaba/dubbo-spring-boot-starter

开源协议:Apache License 2.0

下载


dubbo-spring-boot-starter Maven Central

中文版文档

Dubbo Spring Boot Starter. Dubbo official dubbo-spring-boot-project

Support jdk version 1.6 or 1.6+

(please import googlestyle-java.xml if you want to modify the code)

How to publish dubbo

  • add Dependencies:
  1. <dependency>
  2. <groupId>com.alibaba.spring.boot</groupId>
  3. <artifactId>dubbo-spring-boot-starter</artifactId>
  4. <version>2.0.0</version>
  5. </dependency>
  • add dubbo configuration in application.properties, demo:
  1. spring.application.name=dubbo-spring-boot-starter
  2. spring.dubbo.server=true
  3. spring.dubbo.registry=N/A
  • then add @EnableDubboConfiguration on Spring Boot Application, indicates that dubbo is enabled.(web or non-web application can use dubbo provider)
  1. @SpringBootApplication
  2. @EnableDubboConfiguration
  3. public class DubboProviderLauncher {
  4. //...
  5. }
  • code your dubbo service, add @Service(import com.alibaba.dubbo.config.annotation.Service) on your service class, and interfaceClass is the interface which will be published.
  1. @Service(interfaceClass = IHelloService.class)
  2. @Component
  3. public class HelloServiceImpl implements IHelloService {
  4. //...
  5. }
  • Start Spring Boot.

How to consume Dubbo

  • add Dependencies:
  1. <dependency>
  2. <groupId>com.alibaba.spring.boot</groupId>
  3. <artifactId>dubbo-spring-boot-starter</artifactId>
  4. <version>2.0.0</version>
  5. </dependency>
  • add dubbo configuration in application.properties, demo:
  1. spring.application.name=dubbo-spring-boot-starter
  1. @SpringBootApplication
  2. @EnableDubboConfiguration
  3. public class DubboConsumerLauncher {
  4. //...
  5. }
  • injection interface by the @Reference annotation.
  1. @Component
  2. public class HelloConsumer {
  3. @Reference(url = "dubbo://127.0.0.1:20880")
  4. private IHelloService iHelloService;
  5. }

Reference