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)
- add Dependencies:
<dependency>
<groupId>com.alibaba.spring.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>- add dubbo configuration in application.properties, demo:
spring.application.name=dubbo-spring-boot-starter
spring.dubbo.server=true
spring.dubbo.registry=N/A- then add
@EnableDubboConfigurationon Spring Boot Application, indicates that dubbo is enabled.(web or non-web application can use dubbo provider)
@SpringBootApplication
@EnableDubboConfiguration
public class DubboProviderLauncher {
//...
}- 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.
@Service(interfaceClass = IHelloService.class)
@Component
public class HelloServiceImpl implements IHelloService {
//...
}- Start Spring Boot.
- add Dependencies:
<dependency>
<groupId>com.alibaba.spring.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>- add dubbo configuration in application.properties, demo:
spring.application.name=dubbo-spring-boot-starter- then add
@EnableDubboConfigurationon Spring Boot Application
@SpringBootApplication
@EnableDubboConfiguration
public class DubboConsumerLauncher {
//...
}- injection interface by the
@Referenceannotation.
@Component
public class HelloConsumer {
@Reference(url = "dubbo://127.0.0.1:20880")
private IHelloService iHelloService;
}- dubbo: http://dubbo.io
- spring-boot: http://projects.spring.io/spring-boot
- dubbo-spring-boot-project: https://github.com/dubbo/dubbo-spring-boot-project