目录
3.Spring Boot、Spring Cloud 、Spring Cloud Alibaba的兼容
一.Spring Cloud Alibaba是什么?
快速构件分布式系统的工具集,是Spring Cloud的子项目
分布式/版本化的配置管理:Nacos,ZooKeeper
服务注册与发现:Nacos,Eureka,Zookeeper
路由:Spring Cloud Gateway
端到端的调用:Httputils,RestTemplate,Feign
负载均衡:Ribbon
断路器(服务限流降级):Sentinel
分布式消息(消息驱动能力):SpringCloud Stream + Kafka/RabbitMQ/RocketMQ
二.版本与兼容性
1.Spring Cloud 版本命名
常见版本命名:2.1.5.RELEASE (语义化的版本控制)
解析:
2-主版本(第几代),
1-次版本(一些功能的增加,但是架构没有太大的变化,是兼容的),
5-增量版本(bug修复版本),
RELEASE-正式版(里程碑:SNAPSHOT-开发版 → M-测试版 → RELEASE-正式版 )
Spring Cloud版本命名:见图
是由伦敦地铁站命名,以字母顺序排列 Angel → Brixton → Camden → Dalston → Edgware → Finchley → Greenwich → Hoxton → ......
有很多Spring Cloud子项目都是以这种方式命名的,是为了避免混淆。
后面直接带RELEASE表示的是第一个正式版(如Greenwich.SR)
后面带有SR1(Service Release 1):第一个Bug修复版本(如Greenwich.SR6)
SR → SR1 → SR2 → ......
2.Spring Cloud 生命周期
Spring Cloud 发布规划
Spring Cloud 发布记录
3.Spring Boot、Spring Cloud 、Spring Cloud Alibaba的兼容
4.生产环境如何选择版本
1.不用非稳定版本(SNAPSHOT,M1,M2......)以及end-of-life版本
2.尽量用最新一代的SR2以及以后的版本(新一代的产品往往有行特性)
三.为项目整合Spring Cloud Alibaba
遵循 加依赖 → 写注解 → 写配置 原则。
1.加依赖
先整合Spring Cloud,再整合Spring Cloud Alibaba :整合连接
这里要注意的是Spring Cloud的版本需要与项目使用的Spring Boot版本兼容,
而整合Spring Cloud Alibaba需要与Spring Cloud的版本兼容
下面代码只是举个例子
<dependencyManagement>
<dependencies>
<!--整合spring cloud-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.SR6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!--整合spring cloud alibaba-->
<dependency>
<groupId>org.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.1.3.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
进行整合之后,引入其他模块不需要自己关心版本了。
在spring-cloud-alibaba-dependencies的配置文件中可以看到已经配置好了: