Skip to content

同步代码 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 58 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
c2bb1cb
增加 mapstruct 示例
Apr 17, 2020
7cc3646
增加 mapstruct 示例
Apr 18, 2020
f25926a
增加 MapStruct 入门文章
Apr 18, 2020
bd6815f
修改 README 的目录
Apr 19, 2020
85328ff
dubbo 增加 nacos 注册中心的示例
Apr 25, 2020
7fad871
dubbo 增加 sentinel 服务保障的示例
Apr 26, 2020
b53f0a7
完善 Dubbo 专栏,增加 nacos 和 sentinel 示例
Apr 26, 2020
c1c6b86
提供用于 APIXSIX 负载均衡的项目
May 1, 2020
38a12b5
提供用于 APIXSIX 负载均衡的项目
May 2, 2020
1709f84
增加 Zuul 示例
May 3, 2020
76a566b
增加 Zuul 示例
May 3, 2020
fd35d92
增加 Zuul 示例
May 3, 2020
b89422d
增加 Zuul 示例
May 3, 2020
114b524
增加 Zuul 示例
May 4, 2020
1d89a31
增加 Zuul 示例
May 4, 2020
9f6152b
增加 Zuul 示例
May 4, 2020
4de79d9
增加 Zuul 示例
May 4, 2020
a3be0e9
增加 Zuul 示例
May 4, 2020
38c3e8c
增加 Zuul 示例
May 4, 2020
05b978e
增加 Eureka 示例
May 6, 2020
6de512a
增加 Eureka 示例
May 6, 2020
7e0ecbb
增加 Eureka 示例
May 7, 2020
ff9eca4
增加 Eureka 示例
May 8, 2020
be9278f
增加 Eureka 入门示例
May 8, 2020
caea8cd
增加 Hystrix 入门示例
May 8, 2020
4157610
增加 Hystrix 入门示例
May 12, 2020
e829f55
增加 Hystrix 入门示例
May 12, 2020
55b737d
增加 Hystrix 入门示例
May 12, 2020
9af1942
增加 Hystrix 入门示例(Hystrix Dashboard)
May 13, 2020
8aeb88f
增加 Hystrix 入门示例(Hystrix Turbine)
May 13, 2020
fcdc921
增加 Hystrix 入门示例(Hystrix + Feign)
May 14, 2020
dbbcd00
增加 Hystrix 入门示例(Hystrix + Dubbo)
May 14, 2020
93992e8
增加 Hystrix 入门文章
May 14, 2020
f8949f6
增加 Hystrix 入门文章
May 15, 2020
5d46285
增加 Dubbo + Hystrix 入门示例
May 15, 2020
e0a315b
增加 Dubbo + Hystrix 入门示例
May 15, 2020
85f3f58
增加 Hystrix 入门
May 15, 2020
653a27a
增加 spring boot + feign 示例
May 17, 2020
5e36ed1
增加 spring boot + feign 示例
May 17, 2020
b6a8639
增加 spring boot + feign 示例
May 17, 2020
e7efd57
增加 spring boot + feign 示例
May 18, 2020
7f23fa2
初始化 resilience4j
May 18, 2020
4bb1a7c
resilience4j + CircuitBreaker
May 19, 2020
afe9da9
resilience4j + RateLimiter
May 19, 2020
dc22b23
resilience4j + Bulkhead 示例
May 20, 2020
4cdb91d
resilience4j + retry 示例
May 20, 2020
a7212d4
resilience4j + timelimiter 示例
May 20, 2020
8fb7122
resilience4j + 监控 示例
May 21, 2020
6b75d9a
resilience4j + cloud 示例
May 21, 2020
7a83a81
resilience4j + cloud 示例
May 21, 2020
3929648
resilience4j + cloud 示例
May 21, 2020
7297f47
Resilience4j 入门完成
May 22, 2020
899e867
soul 示例项目
May 22, 2020
19df98f
soul 示例项目
May 23, 2020
bec9ffb
soul 示例项目
May 23, 2020
ff41508
soul 示例项目
May 23, 2020
74de032
soul 学习指南
May 23, 2020
7db69bf
增加 Kong 入门
Jun 1, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 41 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
一个涵盖五个主流技术栈的**正经**仓库:
> 友情提示:因为提供了 50000+ 行示例代码,所以艿艿默认注释了所有 Maven Module。
>
> 胖友可以根据自己的需要,修改 [`pom.xml`](https://github.com/YunaiV/SpringBoot-Labs/blob/master/pom.xml) 即可。

一个涵盖六个主流技术栈的**正经**仓库:
* [《Spring Boot 专栏》](https://github.com/YunaiV/SpringBoot-Labs#spring-boot-%E4%B8%93%E6%A0%8F)
* [《Spring Cloud Alibaba 专栏》](https://github.com/YunaiV/SpringBoot-Labs#spring-cloud-alibaba-%E4%B8%93%E6%A0%8F)
* [《Spring Cloud 专栏》](https://github.com/YunaiV/SpringBoot-Labs#spring-cloud-%E4%B8%93%E6%A0%8F)
Expand Down Expand Up @@ -35,7 +39,7 @@

* [《芋道 Spring Boot 热部署入门》](http://www.iocoder.cn/Spring-Boot/hot-swap/?github) 对应 [lab-48](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-48)
* [《芋道 Spring Boot 消除冗余代码 Lombok 入门》](http://www.iocoder.cn/Spring-Boot/Lombok/?github) 对应 [lab-49](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-49)
* 《芋道 Spring Boot 对象转换 MapStruct 入门》计划中...
* [《芋道 Spring Boot 对象转换 MapStruct 入门》](http://www.iocoder.cn/Spring-Boot/MapStruct/?github) 对应 [lab-55](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-55)

## Web 开发

Expand All @@ -51,6 +55,7 @@
## RPC 开发

* [《芋道 Spring Boot Dubbo 入门》](http://www.iocoder.cn/Spring-Boot/Dubbo/?github) 对应 [lab-30](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-30)
* [《芋道 Spring Boot 声明式调用 Feign 入门》](http://www.iocoder.cn/Spring-Boot/Feign/?github) 对应 [lab-58](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-58)
* 《芋道 Spring Boot Motan 入门》计划中...
* 《芋道 Spring Boot WebService 入门》计划中...
* 《芋道 Spring Boot SOFARPC 入门》计划中...
Expand Down Expand Up @@ -114,8 +119,8 @@
## 服务容错

* [《芋道 Spring Boot 服务容错 Sentinel 入门》](http://www.iocoder.cn/Spring-Boot/Sentinel/?github) 对应 [lab-46](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-46)
* 《芋道 Spring Boot 服务容错 Hystrix 入门》计划中...
* 《芋道 Spring Boot 服务容错 Resilience4j 入门》计划中...
* [《芋道 Spring Boot 服务容错 Hystrix 入门》](http://www.iocoder.cn/Spring-Boot/Hystrix/?github) 对应 [lab-57](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-57)
* [《芋道 Spring Boot 服务容错 Resilience4j 入门》](http://www.iocoder.cn/Spring-Boot/Resilience4j/?github) 对应 [lab-59](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-59)

## 监控管理

Expand Down Expand Up @@ -162,7 +167,7 @@
## 注册中心

* [《芋道 Spring Cloud Alibaba 注册中心 Nacos 入门》](http://www.iocoder.cn/Spring-Cloud-Alibaba/Nacos-Discovery/?github) 对应 [labx-01](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-01)
* 《芋道 Spring Cloud Netflix 注册中心 Eureka 入门》计划中...
* [《芋道 Spring Cloud Netflix 注册中心 Eureka 入门》](http://www.iocoder.cn/Spring-Cloud/Netflix-Eureka?github) 对应 [labx-22](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-22)
* 《芋道 Spring Cloud 注册中心 Zookeeper 入门》计划中...
* 《芋道 Spring Cloud 注册中心 Consul 入门》计划中...
* 《芋道 Spring Cloud 注册中心 Etcd 入门》计划中...
Expand All @@ -176,15 +181,22 @@
## 服务容错

* [《芋道 Spring Cloud Alibaba 服务容错 Sentinel 入门》](http://www.iocoder.cn/Spring-Cloud-Alibaba/Sentinel/?github) 对应 [labx-04](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-04)
* 《芋道 Spring Cloud Netflix 服务容错 Hystrix 入门》计划中...
* 《芋道 Spring Cloud 服务容错 Resilience4j 入门》计划中...
* [《芋道 Spring Cloud Netflix 服务容错 Hystrix 入门》](http://www.iocoder.cn/Spring-Cloud/Netflix-Hystrix/?github) 对应 [labx-23](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-23)
* [《芋道 Spring Cloud 服务容错 Resilience4j 入门》](http://www.iocoder.cn/Spring-Cloud/Resilience4j/?github) 对应 [lab-59](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-59)
* 《芋道 Spring Cloud 服务容错 Spring Cloud CircuitBreaker》计划中...

## API 网关

* [《芋道 Spring Cloud 服务网关 Spring Cloud Gateway 入门》](http://www.iocoder.cn/Spring-Cloud/Spring-Cloud-Gateway/?github) 对应 [labx-08](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-08)
* 《芋道 Spring Cloud Netflix 服务网关 Zuul 入门》计划中...
* [《芋道 Spring Cloud Netflix 服务网关 Zuul 入门》](http://www.iocoder.cn/Spring-Cloud/Netflix-Zuul/?github) 对应 对应 [labx-21](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-21)
* [《性能测试 —— Spring Cloud Gateway、Zuul 基准测试》](http://www.iocoder.cn/Performance-Testing/SpringCloudGateway-Zuul-benchmark/?github) 对应 [lab-07](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-07)

> 如下非 Spring Cloud 网关,先放在这里...

* [《芋道 APISIX 极简入门(国产微服务网关)》](http://www.iocoder.cn/APISIX/install/?github) 对应 [lab-56](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-56)
* [《芋道 Soul 极简入门(国产微服务网关)》](http://www.iocoder.cn/Soul/install/?github) 对应 [lab-60](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-60)
* [《芋道 Kong 极简入门(微服务网关)》](http://www.iocoder.cn/Kong/install/?github) 对应 [lab-56](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-56)

## 配置中心

* [《芋道 Spring Cloud Alibaba 配置中心 Nacos 入门》](http://www.iocoder.cn/Spring-Cloud-Alibaba/Nacos-Config/?github) 对应 [labx-05](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-05)
Expand Down Expand Up @@ -240,19 +252,35 @@
* [《芋道 Spring Boot Dubbo 入门》](http://www.iocoder.cn/Spring-Boot/Dubbo/?github)的[「2. XML 配置」](#)和[「3. 注解配置」](#)小节

**[Nacos](http://www.iocoder.cn/Nacos/install/?github)**
* [《芋道 Spring Boot Dubbo 入门》](http://www.iocoder.cn/Spring-Boot/Dubbo/?github)的[「6. 整合 Nacos」](#)小节
* [《芋道 Spring Cloud Alibaba 服务调用 Dubbo 入门》](http://www.iocoder.cn/Spring-Cloud-Alibaba/Dubbo/?github)的[「2. 快速入门」](#)小节

## 服务保障
## 服务容错

**[Sentinel](http://www.iocoder.cn/Sentinel/install/?github)**
* [《芋道 Spring Boot Dubbo 入门》](http://www.iocoder.cn/Spring-Boot/Dubbo/?github)的[「7. 整合 Sentinel」](#)小节
* [《芋道 Spring Cloud Alibaba 服务调用 Dubbo 入门》](http://www.iocoder.cn/Spring-Cloud-Alibaba/Dubbo/?github)的[「6. 整合 Sentinel」](#)小节

**[Hystrix](http://www.iocoder.cn/categories/Hystrix/?github)**
* [《芋道 Spring Boot 服务容错 Hystrix 入门》](http://www.iocoder.cn/Spring-Boot/Hystrix/?github)的[「6. 集成到 Dubbo」](#)小节
* [《芋道 Spring Cloud Netflix 服务容错 Hystrix 入门》](http://www.iocoder.cn/Spring-Cloud/Netflix-Hystrix/?github)的[「10. 集成到 Dubbo」](#)小节

**[Resilience4j](http://www.iocoder.cn/categories/Resilience4j/?github)**
* [《芋道 Spring Boot 服务容错 Resilience4j 入门》](http://www.iocoder.cn/Spring-Boot/Resilience4j/?github)的[「10. 集成到 Dubbo」](#)小节

## API 网关

* [《芋道 Soul 极简入门(国产微服务网关)》](http://www.iocoder.cn/Soul/install/?github)的[「3. 接入 Dubbo 应用」](#)小节

## 分布式事务

**[Seata](http://www.iocoder.cn/Seata/install/?github)**
* [《芋道 Dubbo 分布式事务 Seata 入门》](http://www.iocoder.cn/Dubbo/Seata/?github) 对应 [lab-53](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-53)
* [《芋道 Spring Cloud Alibaba 分布式事务 Seata 入门》](http://www.iocoder.cn/Spring-Cloud-Alibaba/Seata/?github)的[「2. AT 模式 + Dubbo」](#)小节

**[TCC Transaction](http://www.iocoder.cn/categories/TCC-Transaction/?github)**
* [《TCC-Transaction 源码分析 —— Dubbo 支持》](http://www.iocoder.cn/TCC-Transaction/dubbo-support/?self)

## 链路追踪

**[SkyWalking](http://www.iocoder.cn/SkyWalking/install/?github)**
Expand All @@ -267,7 +295,7 @@

## RocketMQ

* [《RocketMQ 安装部署》](http://www.iocoder.cn/RocketMQ/install/?github)
* [《RocketMQ 极简入门》](http://www.iocoder.cn/RocketMQ/install/?github)
* [《芋道 Spring Boot 消息队列 RocketMQ 入门》](http://www.iocoder.cn/Spring-Boot/RocketMQ/?github) 对应 [lab-31](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-31)
* [《芋道 Spring Cloud Alibaba 消息队列 RocketMQ 入门》](http://www.iocoder.cn/Spring-Cloud-Alibaba/RocketMQ/?github) 对应 [labx-06](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-06)
* [《芋道 Spring Cloud Alibaba 事件总线 Bus RocketMQ 入门》](http://www.iocoder.cn/Spring-Cloud-Alibaba/Bus-RocketMQ/?github) 对应 [labx-20](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-20)
Expand All @@ -277,23 +305,23 @@

## RabbitMQ

* [《RabbitMQ 安装部署》](http://www.iocoder.cn/RabbitMQ/install/?github)
* [《RabbitMQ 极简入门》](http://www.iocoder.cn/RabbitMQ/install/?github)
* [《芋道 Spring Boot 消息队列 RabbitMQ 入门》](http://www.iocoder.cn/Spring-Boot/RabbitMQ/?github) 对应 [lab-04](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-04)
* [《芋道 Spring Cloud 消息队列 RabbitMQ 入门》](http://www.iocoder.cn/Spring-Cloud/RabbitMQ/?github) 对应 [labx-10](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-10)
* [《芋道 Spring Cloud 事件总线 Bus RabbitMQ 入门》](http://www.iocoder.cn/Spring-Cloud/Bus-RabbitMQ/?github) 对应 [labx-19](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-19)
* [《RabbitMQ 书单整理》](http://www.iocoder.cn/Books/RabbitMQ-books-recommended/?github)

## Kafka

* [《Kafka 安装部署》](http://www.iocoder.cn/Kafka/install/?github)
* [《Kafka 极简入门》](http://www.iocoder.cn/Kafka/install/?github)
* [《芋道 Spring Boot 消息队列 Kafka 入门》](http://www.iocoder.cn/Spring-Boot/Kafka/?github) 对应 [lab-03](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-03)
* [《芋道 Spring Cloud 消息队列 Kafka 入门》](http://www.iocoder.cn/Spring-Cloud/Kafka/?github) 对应 [labx-11](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-11)
* [《芋道 Spring Cloud 事件总线 Bus Kafka 入门》](http://www.iocoder.cn/Spring-Cloud/Bus-Kafka/?github) 对应 [labx-18](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-18)
* [《Kafka 书单整理》](http://www.iocoder.cn/Books/Kafka-books-recommended/?github)

## ActiveMQ

* [《ActiveMQ 安装部署》](http://www.iocoder.cn/ActiveMQ/install/?github)
* [《ActiveMQ 极简入门》](http://www.iocoder.cn/ActiveMQ/install/?github)
* [《芋道 Spring Boot 消息队列 ActiveMQ 入门》](http://www.iocoder.cn/Spring-Boot/ActiveMQ/?github) 对应 [lab-32](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-32)
* [《芋道 Spring Cloud 消息队列 ActiveMQ 入门》](http://www.iocoder.cn/Spring-Cloud/ActiveMQ/?github)

Expand Down
2 changes: 1 addition & 1 deletion lab-08/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-data-jpa</artifactId>-->
<!-- <artifa ctId>spring-boot-starter-data-jpa</artifactId>-->
<!-- </dependency>-->

<dependency>
Expand Down
21 changes: 21 additions & 0 deletions lab-30/lab-30-dubbo-annotations-nacos/pom.xml
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>lab-30</artifactId>
<groupId>cn.iocoder.springboot.labs</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>lab-30-dubbo-annotations-nacos</artifactId>
<packaging>pom</packaging>
<modules>
<module>user-rpc-service-api-03</module>
<module>user-rpc-service-provider-03</module>
<module>user-rpc-service-consumer-03</module>
</modules>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?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>lab-30-dubbo-annotations-demo</artifactId>
<groupId>cn.iocoder.springboot.labs</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>user-rpc-service-api-03</artifactId>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cn.iocoder.springboot.lab30.rpc.api;

import cn.iocoder.springboot.lab30.rpc.dto.UserDTO;

/**
* 用户服务 RPC Service 接口
*/
public interface UserRpcService {

/**
* 根据指定用户编号,获得用户信息
*
* @param id 用户编号
* @return 用户信息
*/
UserDTO get(Integer id);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package cn.iocoder.springboot.lab30.rpc.dto;

import java.io.Serializable;

/**
* 用户信息 DTO
*/
public class UserDTO implements Serializable {

/**
* 用户编号
*/
private Integer id;
/**
* 昵称
*/
private String name;
/**
* 性别
*/
private Integer gender;

public Integer getId() {
return id;
}

public UserDTO setId(Integer id) {
this.id = id;
return this;
}

public String getName() {
return name;
}

public UserDTO setName(String name) {
this.name = name;
return this;
}

public Integer getGender() {
return gender;
}

public UserDTO setGender(Integer gender) {
this.gender = gender;
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?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>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>user-rpc-service-consumer-03</artifactId>

<dependencies>
<!-- 引入定义的 Dubbo API 接口 -->
<dependency>
<groupId>cn.iocoder.springboot.labs</groupId>
<artifactId>user-rpc-service-api-03</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>

<!-- 引入 Spring Boot 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

<!-- 实现对 Dubbo 的自动化配置 -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>2.7.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>2.7.4.1</version>
</dependency>

<!-- 使用 Zookeeper 作为注册中心 -->
<!-- <dependency>-->
<!-- <groupId>org.apache.curator</groupId>-->
<!-- <artifactId>curator-framework</artifactId>-->
<!-- <version>2.13.0</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.apache.curator</groupId>-->
<!-- <artifactId>curator-recipes</artifactId>-->
<!-- <version>2.13.0</version>-->
<!-- </dependency>-->

<!-- 使用 Nacos 作为注册中心 -->
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-nacos</artifactId>
<version>2.7.4.1</version>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cn.iocoder.springboot.lab30.rpc;

import cn.iocoder.springboot.lab30.rpc.api.UserRpcService;
import cn.iocoder.springboot.lab30.rpc.dto.UserDTO;
import org.apache.dubbo.config.annotation.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Component;

@SpringBootApplication
public class ConsumerApplication {

public static void main(String[] args) {
// 启动 Spring Boot 应用
ConfigurableApplicationContext context = SpringApplication.run(ConsumerApplication.class, args);
}

@Component
public class UserRpcServiceTest implements CommandLineRunner {

private final Logger logger = LoggerFactory.getLogger(getClass());

@Reference(version = "${dubbo.consumer.UserRpcService.version}")
private UserRpcService userRpcService;

@Override
public void run(String... args) throws Exception {
UserDTO user = userRpcService.get(1);
logger.info("[run][发起一次 Dubbo RPC 请求,获得用户为({})", user);
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# dubbo 配置项,对应 DubboConfigurationProperties 配置类
dubbo:
# Dubbo 应用配置
application:
name: user-service-consumer # 应用名
# Dubbo 注册中心配置
registry:
address: nacos://127.0.0.1:8848 # 注册中心地址。个鞥多注册中心,可见 http://dubbo.apache.org/zh-cn/docs/user/references/registry/introduction.html 文档。
# Dubbo 消费者配置
consumer:
timeout: 1000 # 【重要】远程服务调用超时时间,单位:毫秒。默认为 1000 毫秒,胖友可以根据自己业务修改
UserRpcService:
version: 1.0.0
Loading