forked from wuyouzhuguli/SpringAll
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
9e4267f
commit d0185e6
Showing
11 changed files
with
227 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,14 @@ | ||
<?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>dubbo-boot</artifactId> | ||
<groupId>cc.mrbird</groupId> | ||
<version>1.0</version> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>common-api</artifactId> | ||
|
||
</project> |
5 changes: 5 additions & 0 deletions
5
...ring-Boot-Dubbo-Zookeeper/common-api/src/main/java/cc/mrbird/common/api/HelloService.java
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,5 @@ | ||
package cc.mrbird.common.api; | ||
|
||
public interface HelloService { | ||
String hello(String message); | ||
} |
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,72 @@ | ||
<?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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>cc.mrbird</groupId> | ||
<artifactId>dubbo-boot</artifactId> | ||
<packaging>pom</packaging> | ||
<version>1.0</version> | ||
|
||
<name>dubbo-boot</name> | ||
<description>Spring Boot-Dubbo-ZooKeeper</description> | ||
|
||
<modules> | ||
<module>common-api</module> | ||
<module>server-provider</module> | ||
<module>server-consumer</module> | ||
</modules> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.0.4.RELEASE</version> | ||
<relativePath/> | ||
</parent> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<java.version>1.8</java.version> | ||
<project.version>1.0</project.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<!-- dubbo --> | ||
<dependency> | ||
<groupId>com.alibaba.spring.boot</groupId> | ||
<artifactId>dubbo-spring-boot-starter</artifactId> | ||
<version>2.0.0</version> | ||
</dependency> | ||
<!-- zookeeper --> | ||
<dependency> | ||
<groupId>org.apache.zookeeper</groupId> | ||
<artifactId>zookeeper</artifactId> | ||
<version>3.4.8</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.101tec</groupId> | ||
<artifactId>zkclient</artifactId> | ||
<version>0.10</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>${java.version}</source> | ||
<target>${java.version}</target> | ||
<encoding>${project.build.sourceEncoding}</encoding> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
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,21 @@ | ||
<?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>dubbo-boot</artifactId> | ||
<groupId>cc.mrbird</groupId> | ||
<version>1.0</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>server-consumer</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>cc.mrbird</groupId> | ||
<artifactId>common-api</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
13 changes: 13 additions & 0 deletions
13
40.Spring-Boot-Dubbo-Zookeeper/server-consumer/src/main/java/cc/mrbird/Applicaiton.java
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,13 @@ | ||
package cc.mrbird; | ||
|
||
import com.alibaba.dubbo.spring.boot.annotation.EnableDubboConfiguration; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
@EnableDubboConfiguration | ||
public class Applicaiton { | ||
public static void main(String[] args) { | ||
SpringApplication.run(Applicaiton.class, args); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...ookeeper/server-consumer/src/main/java/cc/mrbird/consumer/controller/HelloController.java
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,19 @@ | ||
package cc.mrbird.consumer.controller; | ||
|
||
import cc.mrbird.common.api.HelloService; | ||
import com.alibaba.dubbo.config.annotation.Reference; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class HelloController { | ||
|
||
@Reference | ||
private HelloService helloService; | ||
|
||
@GetMapping("/hello/{message}") | ||
public String hello(@PathVariable String message) { | ||
return this.helloService.hello(message); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
40.Spring-Boot-Dubbo-Zookeeper/server-consumer/src/main/resources/application.yml
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,15 @@ | ||
server: | ||
port: 8081 | ||
spring: | ||
dubbo: | ||
application: | ||
# 服务名称,保持唯一 | ||
name: server-consumer | ||
# zookeeper地址,用于向其注册服务 | ||
registry: | ||
address: zookeeper://127.0.0.1:2181 | ||
protocol: | ||
# dubbo协议,固定写法 | ||
name: dubbo | ||
# 扫描需要调用服务的类路径 | ||
scan: cc.mrbird.consumer.controller |
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,21 @@ | ||
<?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>dubbo-boot</artifactId> | ||
<groupId>cc.mrbird</groupId> | ||
<version>1.0</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>server-provider</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>cc.mrbird</groupId> | ||
<artifactId>common-api</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
14 changes: 14 additions & 0 deletions
14
40.Spring-Boot-Dubbo-Zookeeper/server-provider/src/main/java/cc/mrbird/Applicaiton.java
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,14 @@ | ||
package cc.mrbird; | ||
|
||
import com.alibaba.dubbo.spring.boot.annotation.EnableDubboConfiguration; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
@EnableDubboConfiguration | ||
public class Applicaiton { | ||
public static void main(String[] args) { | ||
SpringApplication.run(Applicaiton.class, args); | ||
System.out.println("complete"); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...-Zookeeper/server-provider/src/main/java/cc/mrbird/provider/service/HelloServiceImpl.java
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,14 @@ | ||
package cc.mrbird.provider.service; | ||
|
||
import cc.mrbird.common.api.HelloService; | ||
import com.alibaba.dubbo.config.annotation.Service; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Service(interfaceClass = HelloService.class) | ||
@Component | ||
public class HelloServiceImpl implements HelloService { | ||
@Override | ||
public String hello(String message) { | ||
return "hello," + message; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
40.Spring-Boot-Dubbo-Zookeeper/server-provider/src/main/resources/application.yml
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,19 @@ | ||
server: | ||
port: 8080 | ||
spring: | ||
dubbo: | ||
application: | ||
# 服务名称,保持唯一 | ||
name: server-provider | ||
# zookeeper地址,用于向其注册服务 | ||
registry: | ||
address: zookeeper://127.0.0.1:2181 | ||
#暴露服务方式 | ||
protocol: | ||
# dubbo协议,固定写法 | ||
name: dubbo | ||
# 暴露服务端口 (默认是20880,不同的服务提供者端口不能重复) | ||
port: 20880 | ||
server: true | ||
# 扫描需要暴露服务的类路径 | ||
scan: cc.mrbird.provider.service |