|
|
@@ -0,0 +1,145 @@ |
|
|
|
# spring-boot-demo-dubbo-provider |
|
|
|
|
|
|
|
> 此 module 主要是服务提供方示例 |
|
|
|
|
|
|
|
## pom.xml |
|
|
|
|
|
|
|
```xml |
|
|
|
<?xml version="1.0" encoding="UTF-8"?> |
|
|
|
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
|
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
|
|
<parent> |
|
|
|
<artifactId>spring-boot-demo-dubbo</artifactId> |
|
|
|
<groupId>com.xkcoding</groupId> |
|
|
|
<version>1.0.0-SNAPSHOT</version> |
|
|
|
</parent> |
|
|
|
<modelVersion>4.0.0</modelVersion> |
|
|
|
|
|
|
|
<artifactId>spring-boot-demo-dubbo-provider</artifactId> |
|
|
|
|
|
|
|
<properties> |
|
|
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
|
|
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> |
|
|
|
<java.version>1.8</java.version> |
|
|
|
</properties> |
|
|
|
|
|
|
|
<dependencies> |
|
|
|
<dependency> |
|
|
|
<groupId>org.springframework.boot</groupId> |
|
|
|
<artifactId>spring-boot-starter-web</artifactId> |
|
|
|
</dependency> |
|
|
|
|
|
|
|
<dependency> |
|
|
|
<groupId>com.alibaba.spring.boot</groupId> |
|
|
|
<artifactId>dubbo-spring-boot-starter</artifactId> |
|
|
|
<version>${dubbo.starter.version}</version> |
|
|
|
</dependency> |
|
|
|
|
|
|
|
<dependency> |
|
|
|
<groupId>${project.groupId}</groupId> |
|
|
|
<artifactId>spring-boot-demo-dubbo-common</artifactId> |
|
|
|
<version>${project.version}</version> |
|
|
|
</dependency> |
|
|
|
|
|
|
|
<dependency> |
|
|
|
<groupId>com.101tec</groupId> |
|
|
|
<artifactId>zkclient</artifactId> |
|
|
|
<version>${zkclient.version}</version> |
|
|
|
</dependency> |
|
|
|
|
|
|
|
<dependency> |
|
|
|
<groupId>org.projectlombok</groupId> |
|
|
|
<artifactId>lombok</artifactId> |
|
|
|
<optional>true</optional> |
|
|
|
</dependency> |
|
|
|
|
|
|
|
<dependency> |
|
|
|
<groupId>org.springframework.boot</groupId> |
|
|
|
<artifactId>spring-boot-starter-test</artifactId> |
|
|
|
<scope>test</scope> |
|
|
|
</dependency> |
|
|
|
</dependencies> |
|
|
|
|
|
|
|
<build> |
|
|
|
<finalName>spring-boot-demo-dubbo-provider</finalName> |
|
|
|
</build> |
|
|
|
|
|
|
|
</project> |
|
|
|
``` |
|
|
|
|
|
|
|
## application.yml |
|
|
|
|
|
|
|
```yaml |
|
|
|
server: |
|
|
|
port: 9090 |
|
|
|
servlet: |
|
|
|
context-path: /demo |
|
|
|
|
|
|
|
spring: |
|
|
|
dubbo: |
|
|
|
application: |
|
|
|
name: spring-boot-demo-dubbo-provider |
|
|
|
registry: zookeeper://localhost:2181 |
|
|
|
``` |
|
|
|
|
|
|
|
## SpringBootDemoDubboProviderApplication.java |
|
|
|
|
|
|
|
```java |
|
|
|
/** |
|
|
|
* <p> |
|
|
|
* 启动器 |
|
|
|
* </p> |
|
|
|
* |
|
|
|
* @package: com.xkcoding.dubbo.provider |
|
|
|
* @description: 启动器 |
|
|
|
* @author: yangkai.shen |
|
|
|
* @date: Created in 2018-12-25 16:49 |
|
|
|
* @copyright: Copyright (c) 2018 |
|
|
|
* @version: V1.0 |
|
|
|
* @modified: yangkai.shen |
|
|
|
*/ |
|
|
|
@EnableDubboConfiguration |
|
|
|
@SpringBootApplication |
|
|
|
public class SpringBootDemoDubboProviderApplication { |
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
SpringApplication.run(SpringBootDemoDubboProviderApplication.class, args); |
|
|
|
} |
|
|
|
} |
|
|
|
``` |
|
|
|
|
|
|
|
## HelloServiceImpl.java |
|
|
|
|
|
|
|
```java |
|
|
|
/** |
|
|
|
* <p> |
|
|
|
* Hello服务实现 |
|
|
|
* </p> |
|
|
|
* |
|
|
|
* @package: com.xkcoding.dubbo.provider.service |
|
|
|
* @description: Hello服务实现 |
|
|
|
* @author: yangkai.shen |
|
|
|
* @date: Created in 2018-12-25 16:58 |
|
|
|
* @copyright: Copyright (c) 2018 |
|
|
|
* @version: V1.0 |
|
|
|
* @modified: yangkai.shen |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
@Component |
|
|
|
@Slf4j |
|
|
|
public class HelloServiceImpl implements HelloService { |
|
|
|
/** |
|
|
|
* 问好 |
|
|
|
* |
|
|
|
* @param name 姓名 |
|
|
|
* @return 问好 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public String sayHello(String name) { |
|
|
|
log.info("someone is calling me......"); |
|
|
|
return "say hello to: " + name; |
|
|
|
} |
|
|
|
} |
|
|
|
``` |
|
|
|
|