如果您希望将Spring Cloud添加到现有的Spring Boot应用程序中,那么第一步是确定您应该使用的Spring Cloud版本。您在应用程序中使用的版本将取决于您使用的Spring Boot版本。
下表概述了Spring Cloud的哪个版本映射到Spring Boot的哪个版本,即Spring Cloud对Spring Boot版本的匹配依赖关系,如果版本匹配错误,程序启动会报莫名其妙的错误。
Spring Cloud 版本 | Spring Boot 版本 |
2021.0.x aka Jubilee | 2.6.x |
2020.0.x aka Ilford | 2.4.x, 2.5.x (Starting with 2020.0.3) |
2.2.x, 2.3.x (Starting with SR5) | |
2.1.x | |
2.0.x | |
1.5.x | |
1.5.x |
以最新的spring boot 2.6.x版本为例,需要使用spring cloud 2021.0.1版本。
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2021.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
官方地址:Spring Cloud