This repository has been archived by the owner on Dec 12, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
寒鸣
committed
Jan 20, 2017
1 parent
e58e359
commit 29fbfcd
Showing
31 changed files
with
1,868 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/target | ||
/.settings | ||
/.project | ||
/.classpath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
spring-boot-starter-dubbo | ||
=================================== | ||
|
||
[中文版文档](https://github.com/alibaba/spring-boot-starter-dubbo/blob/master/README_zh.md) | ||
|
||
Spring Boot with dubbo support. Dubbo is an RPC framework. | ||
|
||
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: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>spring-boot-starter-dubbo</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</dependency> | ||
``` | ||
* add dubbo configuration in application.properties, demo: | ||
|
||
```properties | ||
spring.dubbo.appname=spring-boot-starter-dubbo-provider-test | ||
spring.dubbo.registry=multicast://224.0.0.0:1111 | ||
spring.dubbo.protocol=dubbo | ||
``` | ||
|
||
* then add `@EnableDubboConfiguration` on Spring Boot Application, indicates that dubbo is enabled.(web or non-web application can use dubbo provider) | ||
|
||
```java | ||
@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. | ||
|
||
```java | ||
@Service(interfaceClass = IHelloService.class) | ||
public class HelloServiceImpl implements IHelloService { | ||
//... | ||
} | ||
``` | ||
|
||
* start Spring Boot. | ||
|
||
|
||
### How to consume Dubbo | ||
|
||
* add Dependencies: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>spring-boot-starter-dubbo</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</dependency> | ||
``` | ||
|
||
* add dubbo configuration in application.properties, demo: | ||
|
||
```properties | ||
spring.dubbo.appname=spring-boot-starter-dubbo-consumer-test | ||
spring.dubbo.registry=multicast://224.0.0.0:1111 | ||
spring.dubbo.protocol=dubbo | ||
``` | ||
|
||
* then add `@EnableDubboConfiguration` on Spring Boot Application | ||
|
||
```java | ||
@SpringBootApplication | ||
@EnableDubboConfiguration | ||
public class DubboConsumerLauncher { | ||
//... | ||
} | ||
``` | ||
|
||
* injection interface by the `@DubboConsumer` annotation. | ||
|
||
```java | ||
@Component | ||
public class HelloConsumer { | ||
@DubboConsumer | ||
private IHelloService iHelloService; | ||
|
||
} | ||
``` | ||
|
||
### Reference | ||
|
||
* dubbo: http://dubbo.io/ | ||
* spring-boot: http://projects.spring.io/spring-boot/ | ||
* spring-boot-starter-dubbo: https://github.com/linux-china/spring-boot-dubbo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
spring-boot-starter-dubbo | ||
=================================== | ||
|
||
[English](https://github.com/alibaba/spring-boot-starter-dubbo/blob/master/README.md) | ||
|
||
Spring Boot with dubbo support. dubbo是一个RPC框架。 | ||
|
||
支持jdk版本为1.6或者1.6+ | ||
|
||
(在修改源码前,请导入googlestyle-java.xml以保证一致的代码格式) | ||
|
||
### 如何发布dubbo服务 | ||
|
||
* 添加依赖: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>spring-boot-starter-dubbo</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</dependency> | ||
``` | ||
|
||
* 在application.properties添加dubbo的相关配置信息,样例配置如下: | ||
|
||
```properties | ||
spring.dubbo.appname=spring-boot-starter-dubbo-provider-test | ||
spring.dubbo.registry=multicast://224.0.0.0:1111 | ||
spring.dubbo.protocol=dubbo | ||
``` | ||
|
||
* 接下来在Spring Boot Application的上添加`@EnableDubboConfiguration`, 表示要开启dubbo功能. (dubbo provider服务可以使用或者不使用web容器) | ||
|
||
```java | ||
@SpringBootApplication | ||
@EnableDubboConfiguration | ||
public class DubboProviderLauncher { | ||
//... | ||
} | ||
``` | ||
|
||
* 编写你的dubbo服务,只需要添加要发布的服务实现上添加`@Service`(import com.alibaba.dubbo.config.annotation.Service)注解 ,其中interfaceClass是要发布服务的接口. | ||
|
||
```java | ||
@Service(interfaceClass = IHelloService.class) | ||
public class HelloServiceImpl implements IHelloService { | ||
//... | ||
} | ||
``` | ||
|
||
* 启动你的Spring Boot应用,观察控制台,可以看到dubbo启动相关信息. | ||
|
||
|
||
### 如何消费Dubbo服务 | ||
|
||
* 添加依赖: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>spring-boot-starter-dubbo</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</dependency> | ||
``` | ||
|
||
* 在application.properties添加dubbo的相关配置信息,样例配置如下: | ||
|
||
```properties | ||
spring.dubbo.appname=spring-boot-starter-dubbo-consumer-test | ||
spring.dubbo.registry=multicast://224.0.0.0:1111 | ||
spring.dubbo.protocol=dubbo | ||
``` | ||
|
||
* 开启`@EnableDubboConfiguration` | ||
|
||
```java | ||
@SpringBootApplication | ||
@EnableDubboConfiguration | ||
public class DubboConsumerLauncher { | ||
//... | ||
} | ||
``` | ||
|
||
* 通过`@DubboConsumer`注入需要使用的interface. | ||
|
||
```java | ||
@Component | ||
public class HelloConsumer { | ||
@DubboConsumer | ||
private IHelloService iHelloService; | ||
} | ||
``` | ||
|
||
### 参考文档 | ||
|
||
* dubbo 介绍: http://dubbo.io/ | ||
* spring-boot 介绍: http://projects.spring.io/spring-boot/ | ||
* spring-boot-starter-dubbo 参考: https://github.com/linux-china/spring-boot-dubbo |
Oops, something went wrong.