-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from gglaochen/feature_zzt
Addition instruction
- Loading branch information
Showing
17 changed files
with
401 additions
and
2 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
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,61 @@ | ||
# Multiple-RPC-DEMO | ||
|
||
在Spring cloud alibaba的基础上,以Nacos为注册中心,提供了两种服务调用方式,默认方式为 Feign,导入Dubbo包之后会使用Dubbo调用 | ||
|
||
## Required | ||
|
||
- JDK1.8 | ||
- maven 3.6+ | ||
|
||
## 项目依赖 | ||
|
||
- Spring cloud Greenwich.SR1 | ||
- Spring boot 2.1.8.RELEASE | ||
- Spring cloud alibaba 2.1.0.RELEASE | ||
- Spring cloud alibaba nacos starter 0.9.0.RELEASE | ||
- Spring cloud starter openfeign 2.1.1.RELEASE | ||
|
||
## Gettging Start | ||
|
||
* 克隆本项目 | ||
|
||
```shell script | ||
git clone https://github.com/gglaochen/invokeReplace.git | ||
``` | ||
|
||
* 将本项目install到本地仓库 | ||
|
||
进入项目invokeReplace路径下执行 | ||
|
||
```shell script | ||
mvn install -DskipTests | ||
``` | ||
|
||
* 在项目pom文件中导入 | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.feign.dubbo.example</groupId> | ||
<artifactId>starter</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</dependency> | ||
``` | ||
|
||
* 替换Dubbo调用方式 | ||
|
||
pom中导入 | ||
|
||
```xml | ||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo</artifactId> | ||
</dependency> | ||
``` | ||
|
||
## sample | ||
|
||
* [multiple-rpc-demo](multiple-rpc-demo) |
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,47 @@ | ||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.feign.dubbo.exmple</groupId> | ||
<artifactId>demo</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<groupId>com.feign.dubbo.example</groupId> | ||
<artifactId>api</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>api</name> | ||
<description>Demo project for Spring Boot</description> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-spring-boot-starter</artifactId> | ||
<version>2.7.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo</artifactId> | ||
<version>2.7.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.feign.dubbo.example</groupId> | ||
<artifactId>starter</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
13 changes: 13 additions & 0 deletions
13
...-demo/multiple-rpc-demo-api/src/main/java/com/feign/dubbo/example/api/ApiApplication.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 com.feign.dubbo.example.api; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class ApiApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(ApiApplication.class, args); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...iple-rpc-demo-api/src/main/java/com/feign/dubbo/example/api/service/DemoHelloService.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 com.feign.dubbo.example.api.service; | ||
|
||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
@FeignClient("provider") | ||
public interface DemoHelloService { | ||
|
||
@GetMapping("/hello") | ||
String sayHello(@RequestParam("msg") String msg); | ||
|
||
} |
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,53 @@ | ||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.feign.dubbo.exmple</groupId> | ||
<artifactId>demo</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<groupId>com.feign.dubbo.example</groupId> | ||
<artifactId>consumer</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>consumer</name> | ||
<description>Demo project for Spring Boot</description> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
</properties> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.feign.dubbo.example</groupId> | ||
<artifactId>api</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.junit.vintage</groupId> | ||
<artifactId>junit-vintage-engine</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
17 changes: 17 additions & 0 deletions
17
...rpc-demo-consumer/src/main/java/com/feign/dubbo/example/consumer/ConsumerApplication.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,17 @@ | ||
package com.feign.dubbo.example.consumer; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; | ||
import org.springframework.cloud.openfeign.EnableFeignClients; | ||
|
||
@SpringBootApplication | ||
@EnableDiscoveryClient | ||
@EnableFeignClients(basePackages = "com.feign.dubbo.example.api") | ||
public class ConsumerApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(ConsumerApplication.class, args); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...mer/src/main/java/com/feign/dubbo/example/consumer/controller/ConsumerDemoController.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 com.feign.dubbo.example.consumer.controller; | ||
|
||
import com.feign.dubbo.example.api.service.DemoHelloService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class ConsumerDemoController { | ||
|
||
@Autowired | ||
private DemoHelloService demoHelloService; | ||
|
||
@GetMapping("/hello") | ||
public String sayHello() { | ||
return demoHelloService.sayHello("Hello World"); | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
multiple-rpc-demo/multiple-rpc-demo-consumer/src/main/resources/application.properties
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,12 @@ | ||
spring.application.name=consumer | ||
|
||
server.port=8081 | ||
|
||
spring.cloud.nacos.discovery.server-addr=localhost:8848 | ||
|
||
dubbo.application.name=consumer | ||
dubbo.registry.address=nacos://localhost:8848 | ||
dubbo.scan.base-packages=com.feign.dubbo.example | ||
dubbo.protocol.name=dubbo | ||
dubbo.protocol.port=12345 | ||
dubbo.protocol.payload=16777216 |
13 changes: 13 additions & 0 deletions
13
...emo-consumer/src/test/java/com/feign/dubbo/example/consumer/ConsumerApplicationTests.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 com.feign.dubbo.example.consumer; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
@SpringBootTest | ||
class ConsumerApplicationTests { | ||
|
||
@Test | ||
void contextLoads() { | ||
} | ||
|
||
} |
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,52 @@ | ||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.feign.dubbo.exmple</groupId> | ||
<artifactId>demo</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<groupId>com.feign.dubbo.example</groupId> | ||
<artifactId>provider</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>provider</name> | ||
<description>Demo project for Spring Boot</description> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.feign.dubbo.example</groupId> | ||
<artifactId>api</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.junit.vintage</groupId> | ||
<artifactId>junit-vintage-engine</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
17 changes: 17 additions & 0 deletions
17
...rpc-demo-provider/src/main/java/com/feign/dubbo/example/provider/ProviderApplication.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,17 @@ | ||
package com.feign.dubbo.example.provider; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; | ||
import org.springframework.cloud.openfeign.EnableFeignClients; | ||
|
||
@SpringBootApplication | ||
@EnableFeignClients(basePackages = "com.feign.dubbo.example.api") | ||
@EnableDiscoveryClient | ||
public class ProviderApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(ProviderApplication.class, args); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...der/src/main/java/com/feign/dubbo/example/provider/service/impl/DemoHelloServiceImpl.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,15 @@ | ||
package com.feign.dubbo.example.provider.service.impl; | ||
|
||
import com.feign.dubbo.example.api.service.DemoHelloService; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class DemoHelloServiceImpl implements DemoHelloService { | ||
|
||
@Override | ||
@GetMapping("/hello") | ||
public String sayHello(String msg) { | ||
return "hello" + msg; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
multiple-rpc-demo/multiple-rpc-demo-provider/src/main/resources/application.properties
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,12 @@ | ||
spring.application.name=provider | ||
|
||
spring.cloud.nacos.discovery.server-addr=localhost:8848 | ||
|
||
dubbo.application.name=provider | ||
dubbo.registry.address=nacos://localhost:8848 | ||
dubbo.scan.base-packages=com.feign.dubbo.example.provider.service.impl | ||
dubbo.protocol.name=dubbo | ||
dubbo.protocol.port=12346 | ||
dubbo.protocol.payload=16777216 | ||
|
||
dubbo.application.qos-enable=false |
13 changes: 13 additions & 0 deletions
13
...emo-provider/src/test/java/com/feign/dubbo/example/provider/ProviderApplicationTests.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 com.feign.dubbo.example.provider; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
@SpringBootTest | ||
class ProviderApplicationTests { | ||
|
||
@Test | ||
void contextLoads() { | ||
} | ||
|
||
} |
Oops, something went wrong.