背景說明
Spring Cloud 自 2015 年 3 月推出之后,很快就在 Java 微服務生態(tài)中,成為開發(fā)人員的首選技術棧。Spring Cloud 在 Spring Boot 的基礎上,保留 Java 開發(fā)習慣,加入分布式特性,提供了一系列通用工具來幫助開發(fā)者在分布式系統(tǒng)里快速構(gòu)建一些常見模式,現(xiàn)在已成為使用范圍最廣的微服務架構(gòu)之一。
Spring Cloud是基于Spring Boot的一整套實現(xiàn)微服務的框架。他提供了微服務開發(fā)所需的配置管理、服務發(fā)現(xiàn)、斷路器、智能路由、微代理、控制總線、全局鎖、決策競選、分布式會話和集群狀態(tài)管理等組件。最重要的是,跟spring boot框架一起使用的話,會讓你開發(fā)微服務架構(gòu)的云服務非常好的方便,Spring Cloud包含了非常多的子框架,其中,Spring Cloud netflix是其中一套框架,由Netflix開發(fā)后來又并入Spring Cloud大家庭,它主要提供的模塊包括:服務發(fā)現(xiàn)、斷路器和監(jiān)控、智能路由、客戶端負載均衡等。
Spring Cloud Netflix是最受歡迎的項目,它是Spring Cloud的一部分,但是Pivotal宣布大部分Spring Cloud Netflix模塊正在進入維護模式,從Spring Cloud Greenwich發(fā)布列車開始,Netflix OSS,Archaius,Hystrix,Ribbon和Zuul正在進入維護模式。這意味著不會向這些模塊添加任何新功能,Spring Cloud團隊只會執(zhí)行一些錯誤修復并修復安全問題。維護模式不包括仍受支持的Eureka模塊。
2017 年,阿里基于 Spring Cloud 推出的 Spring Cloud Alibaba 正式入駐 Spring Cloud 孵化器,并在 2019 年 7 月正式畢業(yè),Spring Cloud Alibaba是基于Spring Cloud Common的規(guī)范實現(xiàn),致力于提供微服務開發(fā)一站式解決方案,此項目包括開發(fā)分布式應用微服務的必需組件,方便開發(fā)者通過Spring Cloud編程模型輕松使用這些組件來開發(fā)分布式應用服務,而Spring Cloud Alibaba的各個微服務組件依賴于Spring Cloud Alibaba自身。
擁抱理由
- Spring Cloud部分組件停止維護和更新,亟需下一個大廠接盤生態(tài)
- 阿里使用過的組件經(jīng)歷了大量考驗,具備較高的穩(wěn)定性和可信度
- 背靠阿里云,盈利模式較好,具備長期維護發(fā)展的潛力和實力
解決方案
工程創(chuàng)建
腳手架提供了通過在線網(wǎng)站創(chuàng)建項目
https://start.aliyun.com/bootstrap.html
https://start.spring.io/
阿里云效提供的腳手架提供了Spring Cloud Alibaba相關的依賴并解決了版本的依賴關系,針對選用Spring Cloud Alibaba生態(tài)建議使用
建議安裝插件Alibaba Cloud Toolkit提供了項目創(chuàng)建入口,不需要再訪問網(wǎng)頁
版本依賴
https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies
https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-dependencies
https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-alibaba-dependencies
選中一個指定版本,然后頁面往下拉找到Managed Dependencies即可看到依賴的版本明細信息
阿里云提供Maven的GAV查詢和下載: https://maven.aliyun.com/mvn/search
開源地址
https://github.com/alibaba/spring-cloud-alibaba
官方文檔
https://spring.io/projects/spring-cloud-alibaba
https://github.com/alibaba/spring-cloud-alibaba/blob/master/README-zh.md
https://github.com/alibaba/spring-cloud-alibaba/wiki/版本說明
版本演進
孵化版本
孵化版本為早期版本,不可用于生產(chǎn)環(huán)境,可以閱讀源碼查看實現(xiàn)思路
| Spring Boot Version | Spring Cloud Version | Spring Cloud Alibaba Version | 備注說明 |
|---|---|---|---|
| 1.5.X.RELEASE | Spring Cloud Edgware | 0.1.X.RELEASE | 最低支持 Edgware.SR5 版本 |
| 2.0.X.RELEASE | Spring Cloud Finchley | 0.2.X.RELEASE | |
| 2.1.X.RELEASE | Spring Cloud Greenwich | 0.9.0.RELEASE |
Spring Cloud Alibaba BOM 包含了它所使用的所有依賴的版本。
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>0.9.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
畢業(yè)版本
| Spring Boot Version | Spring Cloud Version | Spring Cloud Alibaba Version | 備注說明 |
|---|---|---|---|
| 1.5.X.RELEASE | Spring Cloud Edgware | 1.5.1.RELEASE | 停止維護,建議升級 |
| 2.0.X.RELEASE | Spring Cloud Finchley | 2.0.4.RELEASE | 停止維護,建議升級 |
| 2.1.X.RELEASE | Spring Cloud Greenwich | 2.1.2.RELEASE | |
| 2.2.X.RELEASE | Spring Cloud Hoxton.RELEASE | 2.2.0.RELEASE | |
| 2.2.5.RELEASE | Spring Cloud Hoxton.SR3 | 2.2.1.RELEASE | |
| 2.1.13.RELEASE | Spring Cloud Greenwich.SR6 | 2.1.4.RELEASE | |
| 2.2.5.RELEASE | Spring Cloud Hoxton.SR8 | 2.3.2.RELEASE | |
| 2.4.2.RELEASE | Spring Cloud 2020.0 | 2021.1 |
Spring Cloud Alibaba BOM 包含了它所使用的所有依賴的版本。
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.2.5.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
組件版本
| Spring Cloud Alibaba Version | Sentinel Version | Nacos Version | RocketMQ Version | Dubbo Version | Seata Version |
|---|---|---|---|---|---|
| 2.1.0.RELEASE or 2.0.0.RELEASE or 1.5.0.RELEASE | 1.6.3 | 1.1.1 | 4.4.0 | 2.7.3 | 0.7.1 |
| 2.1.1.RELEASE or 2.0.1.RELEASE or 1.5.1.RELEASE | 1.7.0 | 1.1.4 | 4.4.0 | 2.7.3 | 0.9.0 |
| 2.2.0.RELEASE | 1.7.1 | 1.1.4 | 4.4.0 | 2.7.4.1 | 1.0.0 |
| 2.2.1.RELEASE or 2.1.2.RELEASE or 2.0.2.RELEASE | 1.7.1 | 1.2.1 | 4.4.0 | 2.7.6 | 1.2.0 |
| 2.2.3.RELEASE or 2.1.3.RELEASE or 2.0.3.RELEASE | 1.8.0 | 1.3.3 | 4.4.0 | 2.7.8 | 1.3.0 |
| 2.2.5.RELEASE or 2.1.4.RELEASE or 2.0.4.RELEASE | 1.8.0 | 1.4.1 | 4.4.0 | 2.7.8 | 1.3.0 |
補充信息
Spring Cloud里程碑
https://github.com/spring-cloud/spring-cloud-release/milestones
Spring Cloud版本演進
https://github.com/spring-cloud/spring-cloud-release/releases
官方腳手架依賴關系
打開瀏覽器訪問網(wǎng)址查看最新依賴關系:https://start.spring.io/actuator/info
{
"git": {
"branch": "6453e15b56f143d46fdd7eb4f4e3b6df13a8bb10",
"commit": {
"id": "6453e15",
"time": "2021-06-14T12:42:48Z"
}
},
"build": {
"version": "0.0.1-SNAPSHOT",
"artifact": "start-site",
"versions": {
"spring-boot": "2.5.1",
"initializr": "0.11.0-SNAPSHOT"
},
"name": "start.spring.io website",
"time": "2021-06-14T12:44:06.395Z",
"group": "io.spring.start"
},
"bom-ranges": {
"azure": {
"2.2.4": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1",
"3.2.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1",
"3.5.0": "Spring Boot >=2.4.0.M1 and <2.5.0-M1"
},
"codecentric-spring-boot-admin": {
"2.2.4": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1",
"2.3.1": "Spring Boot >=2.3.0.M1 and <2.5.0-M1"
},
"solace-spring-boot": {
"1.0.0": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1",
"1.1.0": "Spring Boot >=2.3.0.M1 and <2.5.0-M1"
},
"solace-spring-cloud": {
"1.0.0": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1",
"1.1.1": "Spring Boot >=2.3.0.M1 and <2.4.0-M1",
"2.0.0": "Spring Boot >=2.4.0.M1 and <2.5.0-M1"
},
"spring-cloud": {
"Hoxton.SR11": "Spring Boot >=2.2.0.RELEASE and <2.3.999.BUILD-SNAPSHOT",
"Hoxton.BUILD-SNAPSHOT": "Spring Boot >=2.3.999.BUILD-SNAPSHOT and <2.4.0.M1",
"2020.0.0-M3": "Spring Boot >=2.4.0.M1 and <=2.4.0.M1",
"2020.0.0-M4": "Spring Boot >=2.4.0.M2 and <=2.4.0-M3",
"2020.0.0": "Spring Boot >=2.4.0.M4 and <=2.4.0",
"2020.0.3": "Spring Boot >=2.4.1 and <2.5.2-SNAPSHOT",
"2020.0.4-SNAPSHOT": "Spring Boot >=2.5.2-SNAPSHOT"
},
"spring-cloud-alibaba": {
"2.2.1.RELEASE": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1"
},
"spring-cloud-gcp": {
"2.0.0": "Spring Boot >=2.4.0-M1 and <2.5.0-M1"
},
"spring-cloud-services": {
"2.2.6.RELEASE": "Spring Boot >=2.2.0.RELEASE and <2.3.0.RELEASE",
"2.3.0.RELEASE": "Spring Boot >=2.3.0.RELEASE and <2.4.0-M1",
"2.4.1": "Spring Boot >=2.4.0-M1 and <2.5.0-M1"
},
"spring-geode": {
"1.2.12.RELEASE": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1",
"1.3.11.RELEASE": "Spring Boot >=2.3.0.M1 and <2.4.0-M1",
"1.4.6": "Spring Boot >=2.4.0-M1 and <2.5.0-M1",
"1.5.0": "Spring Boot >=2.5.0-M1"
},
"vaadin": {
"14.6.3": "Spring Boot >=2.1.0.RELEASE and <2.6.0-M1"
},
"wavefront": {
"2.0.2": "Spring Boot >=2.1.0.RELEASE and <2.4.0-M1",
"2.1.1": "Spring Boot >=2.4.0-M1 and <2.5.0-M1",
"2.2.0": "Spring Boot >=2.5.0-M1"
}
},
"dependency-ranges": {
"native": {
"0.9.0": "Spring Boot >=2.4.3 and <2.4.4",
"0.9.1": "Spring Boot >=2.4.4 and <2.4.5",
"0.9.2": "Spring Boot >=2.4.5 and <2.5.0-M1",
"0.10.0": "Spring Boot >=2.5.0-M1 and <2.5.2-M1",
"0.10.1-SNAPSHOT": "Spring Boot >=2.5.2-M1 and <2.6.0-M1"
},
"okta": {
"1.4.0": "Spring Boot >=2.2.0.RELEASE and <2.4.0-M1",
"1.5.1": "Spring Boot >=2.4.0-M1 and <2.4.1",
"2.0.1": "Spring Boot >=2.4.1 and <2.5.0-M1"
},
"mybatis": {
"2.1.4": "Spring Boot >=2.1.0.RELEASE and <2.5.0-M1",
"2.2.0": "Spring Boot >=2.5.0-M1"
},
"camel": {
"3.3.0": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1",
"3.5.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1",
"3.10.0": "Spring Boot >=2.4.0.M1 and <2.5.0-M1"
},
"open-service-broker": {
"3.1.1.RELEASE": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1",
"3.2.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1",
"3.3.0": "Spring Boot >=2.4.0-M1 and <2.5.0-M1"
}
}
}
其中重點關注如下依賴
- spring-cloud
- spring-cloud-alibaba