目录
Spring 官网地址: https://spring.io/
Spring Boot 官网地址: https://spring.io/projects/spring-boot
Spring Cloud 官网地址: https://spring.io/projects/spring-cloud
Spring Initializr 官网地址: https://start.spring.io/
Spring Boot 官方文档: https://docs.spring.io/spring-boot/docs/
Spring Boot 官方各版本文档: https://docs.spring.io/spring-boot/docs/{版本号}/reference/htmlsingle/
1.如何查看项目中使用的版本?
以下提供了三种查看项目所使用的 Spring 版本的方法:
- 1.通过
代码进行查看:可以查看Spring、Spring Boot版本; - 2.通过
pom.xml进行查看:可以查看Spring Boot、Spring Cloud版本; - 3.通过
mvn命令进行查看:可以查看Spring、Spring Boot、Spring Cloud版本。
下面我们就看下这三种方法的具体使用:
1)通过代码进行查看
可以查看 Spring、Spring Boot 版本。
import org.junit.jupiter.api.Test;
import org.springframework.boot.SpringBootVersion;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.SpringVersion;
@SpringBootTest
class SpringbootDemoApplicationTests {
@Test
public void getSpringVersion() {
String springVersion = SpringVersion.getVersion();
String springBootVersion = SpringBootVersion.getVersion();
System.out.println("springVersion: " + springVersion);
System.out.println("springBootVersion: " + springBootVersion);
}
}
执行结果:

从代码打印结果可以看到:
Spring版本为5.1.14.RELEASE;Spring Boot版本为2.1.13.RELEASE。
2)通过 pom.xml 进行查看
可以查看 Spring Boot、Spring Cloud 版本。
<!-- Spring Boot(集成方式1:parent) -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.13.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<!-- Spring Boot(集成方式2:单独引用dependency) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.13.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- Spring Boot(集成方式3:集中引用) -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!-- Spring Cloud -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.SR3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
从 pom.xml 中可以看到:
spring-boot-starter-web和spring-boot-dependencies版本为2.1.13.RELEASE;spring-cloud-dependencies版本为Greenwich.SR3。
3)通过 mvn 命令进行查看
可以查看 Spring、Spring Boot、Spring Cloud 版本。
mvn dependency:tree
执行结果:
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.1.13.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.1.13.RELEASE:compile
[INFO] | | +- ...
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.1.13.RELEASE:compile
[INFO] | | +- ...
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.1.13.RELEASE:compile
[INFO] | | +- ...
[INFO] | +- org.hibernate.validator:hibernate-validator:jar:6.0.18.Final:compile
[INFO] | | - ...
[INFO] | +- org.springframework:spring-web:jar:5.1.14.RELEASE:compile
[INFO] | | - ...
[INFO] | - org.springframework:spring-webmvc:jar:5.1.14.RELEASE:compile
从 mvn 命令执行结果可以看到:
spring-web和spring-webmvc版本5.1.14.RELEASE;spring-boot-starter-web版本为2.1.13.RELEASE;Spring Cloud版本可以通过Spring Boot的版本对应到Greenwich。
2.Spring Boot 和 Spring 版本对应关系
1)根据官网判断
Spring Boot 官网:https://spring.io/projects/spring-boot#learn
(GA General Availability 表示官方确认发布的稳定版本)

Spring Boot 官网 RELEASE 版本清单:https://github.com/spring-projects/spring-boot/wiki#release-notes

可以点击官网中相应的版本,查看版本的说明文档,如果文档中没有 Spring Framework 相关内容,则表示 Spring Framework 没有版本升级,可以再看下再之前的版本,使用的是什么的版本。
例如:Spring Boot 3.0 版本中升级了 Spring 6,文档中就会有说明:

2)根据官方文档判断
Spring Boot 官方文档: https://docs.spring.io/spring-boot/docs/
Spring Boot 官方各版本文档: https://docs.spring.io/spring-boot/docs/版本号/reference/htmlsingle/
注意: 由于官方文档比较大,用浏览器访问会有点卡顿。
Tips: 在官方文档中直接搜索
Requirements就可以看到Spring Boot所依赖的Java、Spring Framework、Tomcat等版本信息。(1.2.0.RELEASE 之后 Requirements 的描述比较完善。)
2.1)查看具体版本的官方文档
例如:想查看 2.1.13.RELEASE 版本的官方文档,可以访问如下地址:
https://docs.spring.io/spring-boot/docs/2.1.13.RELEASE/reference/htmlsingle/

2.2)查看大版本的官方文档
例如:想查看 2.1.x 大版本的官方文档,可以访问如下地址:
https://docs.spring.io/spring-boot/docs/2.1.x/reference/htmlsingle/

3)根据 Maven 仓库判断
Maven仓库地址: https://mvnrepository.com/
从 Maven 仓库中搜索相应的 spring-boot-starter-web 包,查看详情可以看到该 jar 包底层是依赖于哪些包。

3)根据官方文档整理的版本对应信息【核心】
下面梳理了 SpringBoot 从 1.0.0.RELEASE 到 3.0.4 版本所对应的 Spring、JDK、Maven 版本信息。
(点击版本号进入相应版本的官方文档)
Spring Boot 版本
Spring Framework 版本
JDK 版本
Maven 版本


6920

被折叠的 条评论
为什么被折叠?



