第01章-简介
# 1.1 什么是Spring Cloud
快速构建分布式系统的工具集
主要功能:
功能 | 翻译 | 选择 |
---|---|---|
Distributed/versioned | 分布式/版本化的配置管理 | Spring Cloud Config、Consul、Nacos、configuration、Zookeeper |
Seruice registration and discovery | 服务注册与服务发现 | Eureka、Consul、Nacos、Zokeeper |
Routing | 路由 | Zuul、Spring Cloud Gateway |
Service-to-service calls | 端到端的调用 | RestTemplate、Feign |
Load balancing | 负载均衡 | Ribbon |
Circuit Breakers | 断路器 | Hystrix、Sentinel、Resilience4J |
Global locks | 全局锁 | Sprng cloud custer(已证移到Spring Integration) |
Leadership election and cluster state | 选举与集群状态管理 | Spring Cloud Cluster(已迁移到Spring Integration) |
Distributed messaging | 分布式消息 | Spring Cloud Stream + Kafka/RabbitMQ/RocketMQ |
# 1.2 什么是Spring Cloud Alibaba
阿里巴巴结合自身微服务实践,开源的微服务全家桶,在Spring Cloud项目中孵化,很可能成为Spring Cloud第二代的标准实现。 在业界广泛使用,已有很多成功案例。
- Spring Cloud的子项目
- 致力于提供微服务开发的一站式解决方案。
- 包含微服务开发的必备组件
- 基于Spring Cloud,符合Spring Cloud标准
- 阿里的微服务解决方案
主要功能
功能 | 产品 | 备注 |
---|---|---|
服务限流降级 | Sentinel | 开源组件 |
服务注册与发现 | Nacos、ANS | 开源组件、商业组件 |
分布式配置管理 | Nacos、ANS | 开源组件、商业组件 |
消息驱动能力 | Spring Cloud Stream、RocketMQ | 开源组件 |
分布式事务 | Seata | 开源组件,不能用于生产(目前0.6.1),1.0.0之后才可用于生产 |
阿里云对象存储 | oss | 商业组件 |
分布式任务调 | SchedulerX | 商业组件 |
阿里云短信服务 | SMS | 商业组件 |
# 1.3 Spring Cloud Alibaba 和 Spring Cloud 的区别
总体来说,Spring Cloud Alibaba有以下优势:
- 组件性能更强
- 良好的可视化界面
- 搭建简单,学习曲线低
- 文档丰富并且是中文
# 1.4 Spring Boot整合
<dependencyManagement>
<!-- 1. 整合Spring Cloud -->
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>{spring-cloud-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
<!-- 2. 整合Spring Cloud Alibaba -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.2.4.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencyManagement>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
编辑 (opens new window)
上次更新: 2023/06/04, 12:34:19