关于升级 spring-boot 4 版本的问题
2026/5/9大约 1 分钟
升级后依赖问题
spring-boot-starter-aop
由于 spring-boot 4 之后,原来的 aop 包名废弃,需要使用新的包名 spring-boot-starter-aspectj。
pom 文件需要如下修改:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aspectj</artifactId>
<version>4.0.4</version> <!-- 如果前面有引 parent 依赖,这里可以省略 -->
</dependency>mybatis-plus
在 spring-boot 3 时,我们引入的 mybatis-plus 依赖是 mybatis-plus-spring-boot3-starter 现在需要升级为 mybatis-plus-spring-boot4-starter。
pom 文件需要如下修改:
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot4-starter</artifactId>
<version>3.5.16</version> <!-- 如果前面有引 parent 依赖,这里可以省略 -->
</dependency>虚拟线程
如果需要开启虚拟线程,需要在 application.properties 或 application.yml 中添加如下配置:
yaml 配置
spring:
virtual-thread:
enabled: trueproperties 配置
spring.virtual-thread.enabled=true同时由于虚拟线程是 jdk 19 之后的功能,需要在 pom 文件或 gradle 文件中添加编译配置:
因为本人不使用 gradle,所以关于 gradle 的配置仅供参考。
pom 配置
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
</properties>
<!-- 其他依赖... -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.9.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
</plugins>
</build>gradle 配置
java {
sourceCompatibility = JavaVersion.VERSION_19
targetCompatibility = JavaVersion.VERSION_19
}更新日志
2026/5/9 08:25
查看所有更新日志
e20a0-于
