Spring Boot 4.1.0 深度实战:50+ 依赖升级背后的架构演进与性能优化完全指南
2026年6月10日,Spring官方团队正式发布Spring Boot 4.1.0。这是4.x系列继2025年11月20日发布v4.0.0以来的首个功能更新版本。看似一个".1"的小版本号,实则暗藏玄机——50+项核心依赖升级、30+个Bug修复、多项安全加固,以及一个让微服务开发者直呼"终于等到你"的WritableJson内存优化。
本文将从架构演进、性能优化、安全加固、迁移实战四个维度,深度剖析Spring Boot 4.1.0的技术内幕,帮助你理解这个版本为何被称为"4.x系列的稳定之锚"。
一、发布概况:为什么4.1.0比4.0.0更值得关注
1.1 版本定位:稳定之锚而非颠覆者
Spring Boot 4.0.0于2025年11月20日发布,带来了Java 25最低版本要求、Jakarta EE 11全面迁移、Spring Framework 7.x核心升级等一系列"破坏性"变更。对于企业级项目而言,4.0.0是一个需要谨慎评估的"大版本跳跃"。
而4.1.0的定位截然不同——它不是来颠覆的,而是来稳定的。从官方Release Notes可以看出,本次更新的重心已从"功能兼容性"转向"安全加固和性能优化"。这意味着:
- API稳定性:4.0废弃的API已全部移除,4.1不会有新的破坏性变更
- 依赖成熟度:Hibernate 7.4、Spring Security 7.1、Spring Framework 7.0.8都是经过半年打磨的稳定版本
- 生态兼容性:从ActiveMQ到SQLite JDBC,50+依赖已在新版本上充分验证
用一句话总结:如果你还在观望4.0.x,4.1.0就是那个值得跳过的版本。
1.2 核心依赖版本全景
| 依赖 | 旧版(4.0.x) | 新版(4.1.0) | 变更要点 |
|---|---|---|---|
| Spring Framework | 7.0.x | 7.0.8 | 核心框架优化 |
| Spring Security | 7.0.x | 7.1.0 | JWT严格校验 |
| Spring Data | 2025.x | 2026.0.0 | 年度大版本 |
| Hibernate | 7.3.x | 7.4.1.Final | ORM稳定性与性能 |
| Tomcat | 11.0.x | 11.0.22 | 容器安全修复 |
| Jetty | 12.1.x | 12.1.10 | Servlet容器 |
| Kafka | 4.1.x | 4.2.1 | 消息吞吐优化 |
| Kotlin | 2.2.x | 2.3.21 | 语言特性更新 |
| Micrometer | 1.16.x | 1.17.0 | 监控指标增强 |
| OpenTelemetry | 1.61.x | 1.62.0 | 可观测性完善 |
| Reactor | 2025.0.x | 2025.0.6 | 响应式编程 |
| Jackson | 2.20.x | 2.21.4 | JSON处理 |
| Netty | 4.2.x | 4.2.15.Final | 网络框架 |
| Logback | 1.5.x | 1.5.34 | 日志实现 |
关键观察:
- 安全三件套全线升级:Spring Security 7.1.0 + Nimbus JWT严格校验 + Tomcat 11.0.22安全修复
- 数据栈年度焕新:Spring Data 2026.0.0 + Hibernate 7.4.1 + Kafka 4.2.1
- 可观测性生态闭环:Micrometer 1.17.0 + OpenTelemetry 1.62.0 + Micrometer Tracing 1.7.0
二、新功能深度解析:WritableJson内存优化是本次最大亮点
2.1 WritableJson内存优化:微服务GC压力的救星
Issue #49428:减少反复调用WritableJson.toByteArray时的内存消耗
这是一个看似微小但影响深远的优化。让我们深入理解它的技术原理和实际价值。
2.1.1 问题背景
在Spring Boot 4.0.x中,WritableJson类(用于Jackson JSON序列化包装)的toByteArray()方法存在一个性能陷阱:
// Spring Boot 4.0.x 的实现逻辑(简化)
public class WritableJson {
private final Object value;
private final ObjectMapper objectMapper;
public byte[] toByteArray() {
try {
return objectMapper.writeValueAsBytes(value);
} catch (JsonProcessingException e) {
throw new RuntimeJsonException(e);
}
}
}
每次调用toByteArray()都会触发完整的序列化过程,产生新的byte数组。对于以下场景,这个问题被放大:
- REST API响应:每次请求都生成JSON响应
- Actuator健康检查:K8s每10秒探测一次,每次都序列化健康状态
- Prometheus指标暴露:
/actuator/prometheus端点每15秒被抓取一次 - 分布式追踪:每个请求的Span信息都需要序列化
在高并发场景下,一个微服务实例每秒可能产生数千次JSON序列化,导致:
- Young GC频繁:大量临时byte数组快速填满Eden区
- 内存带宽压力:序列化+复制+GC三重开销
- CPU利用率虚高:重复序列化相同对象
2.1.2 优化方案
Spring Boot 4.1.0引入了缓存机制:
// Spring Boot 4.1.0 的实现逻辑(简化)
public class WritableJson {
private final Object value;
private final ObjectMapper objectMapper;
private volatile byte[] cachedBytes; // 新增缓存
private final Object lock = new Object();
public byte[] toByteArray() {
if (cachedBytes != null) {
return cachedBytes;
}
synchronized (lock) {
if (cachedBytes != null) {
return cachedBytes;
}
try {
cachedBytes = objectMapper.writeValueAsBytes(value);
return cachedBytes;
} catch (JsonProcessingException e) {
throw new RuntimeJsonException(e);
}
}
}
}
2.1.3 性能提升实测
官方基准测试数据显示:
| 场景 | 4.0.x GC次数/分钟 | 4.1.0 GC次数/分钟 | 改善幅度 |
|---|---|---|---|
| REST API (1000 QPS) | 120 | 75 | 37.5% |
| Actuator健康检查 (K8s) | 45 | 28 | 37.8% |
| Prometheus指标暴露 | 60 | 38 | 36.7% |
内存占用对比(相同负载下):
- Young Generation峰值:降低30-50%
- 内存带宽占用:降低约40%
- GC暂停时间:缩短35%
2.1.4 最佳实践
@RestController
@RequestMapping("/api/users")
public class UserController {
private final UserService userService;
private final ObjectMapper objectMapper;
// 方式1:利用Spring Boot自动配置的ObjectMapper
@GetMapping("/{id}")
public ResponseEntity<User> getUser(@PathVariable Long id) {
return ResponseEntity.ok(userService.findById(id));
// Spring Boot自动使用WritableJson包装响应
}
// 方式2:手动控制缓存策略(适用于频繁访问的静态数据)
@GetMapping("/config")
public ResponseEntity<byte[]> getConfig() {
// 对于不变配置,使用缓存版本
return ResponseEntity.ok()
.contentType(MediaType.APPLICATION_JSON)
.body(cachedConfigBytes);
}
}
注意事项:
- 缓存适用于只读或低频变更的场景
- 对于频繁变更的对象,每次序列化内容不同,缓存效果有限
- 分布式环境下需注意缓存一致性
2.2 异常处理增强:链式Cause追踪
Issue #50211:InvalidConfigurationPropertyValueException新增public构造函数,支持传入cause链
2.2.1 问题背景
在Spring Boot 4.0.x中,配置属性验证失败时的异常信息不够完整:
// 4.0.x 的异常构造
public InvalidConfigurationPropertyValueException(
String propertyName, Object value, String reason) {
super("Property '" + propertyName + "' has invalid value: " + value +
" (" + reason + ")");
// 问题:无法携带Root Cause
}
当配置验证依赖外部服务(如数据库连接验证、远程配置中心)时,异常链断裂:
InvalidConfigurationPropertyValueException: Property 'datasource.url' has invalid value
at com.example.ConfigValidator.validate(ConfigValidator.java:45)
... 15 more
// 真正的原因(如DNS解析失败、网络超时)丢失了
2.2.2 优化方案
// 4.1.0 新增的构造函数
public InvalidConfigurationPropertyValueException(
String propertyName, Object value, String reason, Throwable cause) {
super("Property '" + propertyName + "' has invalid value: " + value +
" (" + reason + ")", cause);
// 现在可以完整保留异常链
}
2.2.3 实战应用
@ConfigurationProperties(prefix = "app.datasource")
@Validated
public class DataSourceProperties {
@NotNull
private String url;
@NotNull
private String username;
// 自定义验证器
@Bean
public ConfigurationPropertiesValidator dataSourceValidator() {
return new ConfigurationPropertiesValidator() {
@Override
public void validate(Object target, Errors errors) {
DataSourceProperties props = (DataSourceProperties) target;
try {
// 尝试建立连接验证配置
testConnection(props.getUrl(), props.getUsername());
} catch (SQLException e) {
// 4.1.0:可以完整传递Root Cause
errors.rejectValue("url", "invalid.datasource.connection",
new Object[]{e.getMessage()}, "Database connection test failed");
throw new InvalidConfigurationPropertyValueException(
"app.datasource.url", props.getUrl(),
"Connection test failed: " + e.getMessage(), e);
}
}
};
}
}
日志输出对比:
// 4.0.x
2026-06-10 10:30:15 ERROR [main] o.s.b.SpringApplication - Application run failed
InvalidConfigurationPropertyValueException: Property 'datasource.url' has invalid value
// 4.1.0
2026-06-10 10:30:15 ERROR [main] o.s.b.SpringApplication - Application run failed
InvalidConfigurationPropertyValueException: Property 'datasource.url' has invalid value
at com.example.ConfigValidator.validate(ConfigValidator.java:45)
Caused by: java.net.UnknownHostException: db.example.com
at java.net.InetAddress.getAllByName(InetAddress.java:1350)
... 5 more
运维人员可以直接定位到DNS解析失败,而非模糊的"invalid value"。
2.3 Spring Security 7.1.0集成:JWT安全加固
2.3.1 NimbusJwtDecoder严格校验
Issue #50228:不再静默接受未知的jws-algorithms值
这是一个重要的安全修复。在Spring Security 7.0.x中,NimbusJwtDecoder对JWT算法头的校验过于宽松:
// 7.0.x 的行为(有风险)
public class NimbusJwtDecoder {
public Jwt decode(String token) {
JWSHeader header = parseHeader(token);
JWSAlgorithm algorithm = header.getAlgorithm();
// 问题:接受任意算法值,包括非标准、潜在危险的算法
if (!SUPPORTED_ALGORITHMS.contains(algorithm)) {
// 7.0.x:静默降级,使用默认算法
algorithm = JWSAlgorithm.RS256;
}
return verifySignature(token, algorithm);
}
}
安全风险:
- 算法混淆攻击:攻击者可能将RS256改为HS256,利用公钥作为HMAC密钥
- None算法攻击:某些实现可能接受"none"算法绕过签名验证
- 弱算法降级:强制降级到较弱算法
2.3.2 修复方案
// 7.1.0 的行为(严格)
public class NimbusJwtDecoder {
private static final Set<JWSAlgorithm> ALLOWED_ALGORITHMS =
Set.of(
JWSAlgorithm.RS256, JWSAlgorithm.RS384, JWSAlgorithm.RS512,
JWSAlgorithm.ES256, JWSAlgorithm.ES384, JWSAlgorithm.ES512,
JWSAlgorithm.PS256, JWSAlgorithm.PS384, JWSAlgorithm.PS512
);
public Jwt decode(String token) {
JWSHeader header = parseHeader(token);
JWSAlgorithm algorithm = header.getAlgorithm();
if (!ALLOWED_ALGORITHMS.contains(algorithm)) {
throw new JwtValidationException(
"Unsupported JWS algorithm: " + algorithm +
". Allowed algorithms: " + ALLOWED_ALGORITHMS);
}
return verifySignature(token, algorithm);
}
}
2.3.3 迁移建议
如果你的JWT提供方使用非标准算法:
# application.yml
spring:
security:
oauth2:
resourceserver:
jwt:
jws-algorithms: RS256,ES256,custom-alg-1 # 显式声明允许的算法
或通过代码配置:
@Bean
public JwtDecoder jwtDecoder() {
return NimbusJwtDecoder.withJwkSetUri(jwkSetUri)
.jwsAlgorithms(algorithms -> {
algorithms.add(JWSAlgorithm.RS256);
algorithms.add(JWSAlgorithm.ES256);
// 添加自定义算法(需确保安全性)
algorithms.add(new JWSAlgorithm("custom-alg-1"));
})
.build();
}
三、安全修复:7项关键安全加固详解
3.1 安全修复清单
| Issue | 问题 | 影响 | 修复方式 |
|---|---|---|---|
| #50747 | MailSender自动配置未启用主机名验证 | 邮件服务器可能被中间人攻击 | 强制启用主机名验证 |
| #50745 | Artemis自动配置使用可预测的数据路径 | 嵌入式消息代理安全风险 | 使用随机路径 |
| #50700 | LDAP SSL在证书为空时不应启用 | 避免错误的安全配置 | 增加证书非空检查 |
| #50668 | InetAddressFilter未排除RFC 6890特殊用途地址 | 潜在网络过滤绕过 | 完善地址过滤逻辑 |
| #50635 | SSL Bundle被覆盖为空字符串时未禁用SSL | 安全配置不一致 | 空字符串视为禁用 |
| #50612 | RabbitProperties在SSL bundle被覆盖时仍启用SSL | 连接安全问题 | 统一SSL处理逻辑 |
| #50228 | NimbusJwtDecoder静默接受未知jws-algorithms | JWT验证绕过风险 | 严格算法白名单 |
3.2 深度解析:MailSender主机名验证
3.2.1 问题背景
// 4.0.x 的 MailProperties 配置
@ConfigurationProperties(prefix = "spring.mail")
public class MailProperties {
private String host;
private Integer port;
private String username;
private String password;
private Boolean sslEnabled;
// 问题:缺少主机名验证配置
}
在SSL/TLS连接中,主机名验证是防止中间人攻击的关键环节。4.0.x版本默认不启用主机名验证,导致:
- 证书域名不匹配:攻击者可能使用合法但域名不匹配的证书
- DNS劫持:攻击者将mail.example.com解析到恶意服务器
- 内网钓鱼:攻击者部署自签名证书的邮件服务器
3.2.2 修复方案
// 4.1.0 的 JavaMailSenderImpl 配置
public class JavaMailSenderImpl implements JavaMailSender {
@Override
protected Session buildSession() {
Properties props = new Properties();
// 新增:强制启用主机名验证
props.put("mail.smtp.ssl.checkserveridentity", "true");
props.put("mail.imap.ssl.checkserveridentity", "true");
props.put("mail.pop3.ssl.checkserveridentity", "true");
return Session.getInstance(props);
}
}
3.2.3 自定义配置
如果你的邮件服务器证书域名与主机名不一致:
spring:
mail:
host: mail.example.com
port: 587
username: user@example.com
password: secret
properties:
mail:
smtp:
ssl:
checkserveridentity: false # 仅在测试环境禁用
trust: mail.internal.example.com # 信任特定域名
安全建议:生产环境务必保持checkserveridentity: true,并确保证书域名与邮件服务器主机名匹配。
3.3 深度解析:SSL Bundle配置一致性
3.3.1 问题背景
// 4.0.x 的行为
@ConfigurationProperties(prefix = "spring.rabbitmq")
public class RabbitProperties {
private String host;
private int port;
private Ssl ssl = new Ssl();
public static class Ssl {
private boolean enabled = false;
private String bundle; // SSL Bundle名称
}
}
// 场景:用户配置错误
spring:
rabbitmq:
ssl:
bundle: "" # 空字符串
# 预期:禁用SSL
// 实际:enabled仍为false,但bundle为空字符串时行为未定义
这导致SSL配置状态不一致,可能出现:
- 连接失败:客户端期望明文连接,服务端要求TLS
- 安全降级:敏感数据通过明文传输
- 调试困难:配置与行为不匹配
3.3.2 修复方案
// 4.1.0 的逻辑
public SslBundle getSslBundle(ApplicationContext context) {
if (ssl.getBundle() == null || ssl.getBundle().isEmpty()) {
// 空字符串等同于未配置
return ssl.isEnabled() ? SslBundle.ofDefault() : null;
}
return context.getBean(SslBundles.class).getBundle(ssl.getBundle());
}
四、性能优化:从依赖升级到架构演进
4.1 直接性能改进
| 改进点 | 说明 | 适用场景 | 性能提升 |
|---|---|---|---|
| WritableJson内存优化 | 减少反复序列化的内存消耗 | REST API、监控指标 | GC次数降低35%+ |
| Logback 1.5.34 | 日志性能持续优化 | 高并发日志场景 | 吞吐量提升约10% |
| Netty 4.2.15 | 网络层性能和安全修复 | 响应式/WebFlux | 连接处理优化 |
| Tomcat 11.0.22 | Servlet容器稳定性和性能 | 传统Servlet应用 | 请求处理优化 |
| Micrometer 1.17.0 | 指标采集性能优化 | 可观测性场景 | 指标收集开销降低 |
4.2 生态系统性能提升链路
Hibernate 7.3.x → 7.4.1.Final
├── 查询缓存优化
├── 批量插入性能提升
└── 实体图加载优化
Kafka 4.1.x → 4.2.1
├── 生产者吞吐量提升15%
├── 消费者延迟降低
└── 分区重平衡优化
Spring Data 2025.x → 2026.0.0
├── Repository查询优化
├── 分页查询内存占用降低
└── 投影查询性能提升
4.3 GraalVM Native Build Tools 1.1.1
Spring Boot在GraalVM原生编译方向上持续演进:
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>1.1.1</version>
<configuration>
<buildArgs>
<buildArg>--no-fallback</buildArg>
<buildArg>--initialize-at-build-time=org.slf4j</buildArg>
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
</buildArgs>
</configuration>
</plugin>
性能对比(相同应用,不同运行模式):
| 运行模式 | 启动时间 | 内存占用 | 峰值吞吐量 |
|---|---|---|---|
| JVM (Java 25) | 2.8s | 256MB | 10000 req/s |
| GraalVM Native (4.0.x) | 0.15s | 64MB | 9500 req/s |
| GraalVM Native (4.1.0) | 0.12s | 58MB | 9800 req/s |
注意:GraalVM Native仍有局限性:
- 反射配置复杂
- 动态代理受限
- 部分库不完全兼容
五、迁移实战:从4.0.x和3.5.x升级指南
5.1 从4.0.x升级
5.1.1 升级前检查清单
# 1. 检查废弃API调用
./mvnw spring-boot:run -Dspring-boot.run.profiles=deprecation
# 2. 运行测试套件
./mvnw test
# 3. 检查Derby使用情况
grep -r "derby" src/
5.1.2 关键迁移步骤
<!-- pom.xml -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>4.1.0</version>
</parent>
# application.yml 迁移注意事项
# 1. Derby数据源迁移
spring:
datasource:
# 旧配置(已废弃)
# url: jdbc:derby:memory:testdb;create=true
# 新配置(推荐H2)
url: jdbc:h2:mem:testdb
driver-class-name: org.h2.Driver
# 2. GraphQL WebSocket配置
spring:
graphql:
websocket:
allowed-origins: "https://example.com" # 新增必需配置
# 3. JWT算法配置
spring:
security:
oauth2:
resourceserver:
jwt:
jws-algorithms: RS256,ES256 # 显式声明
5.1.3 测试验证
@SpringBootTest
class MigrationTests {
@Test
void testJsonSerializationPerformance() {
// 验证WritableJson优化生效
ResponseEntity<String> response = restTemplate.getForEntity(
"/api/users/1", String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@Test
void testSecurityConfiguration() {
// 验证JWT严格校验
String invalidJwt = createJwtWithUnknownAlgorithm();
ResponseEntity<String> response = restTemplate.getForEntity(
"/api/protected?token=" + invalidJwt, String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}
}
5.2 从3.5.x升级(跨大版本)
5.2.1 升级路径
3.5.x → 4.0.x → 4.1.0
建议:直接跳过4.0.x,升级到4.1.0
5.2.2 关键变更
| 变更项 | 3.5.x | 4.1.0 | 迁移工作量 |
|---|---|---|---|
| Java版本 | 17+ | 25+ | 升级JDK |
| EE规范 | javax.* | jakarta.* | 全局替换 |
| Spring Framework | 6.x | 7.0.8 | API变更 |
| Hibernate | 6.x | 7.4.1 | 查询语法 |
| Spring Security | 6.x | 7.1.0 | 配置模型 |
5.2.3 自动化迁移脚本
#!/bin/bash
# migrate-to-spring-boot-4.sh
# 1. 替换javax为jakarta
find src -type f -name "*.java" -exec sed -i '' 's/javax\./jakarta./g' {} +
# 2. 更新依赖版本
sed -i '' 's/spring-boot-starter-parent.*version>.*/version>4.1.0<\/version>/' pom.xml
# 3. 更新Spring Security配置(示例)
find src -type f -name "*.java" -exec sed -i '' 's/extends WebSecurityConfigurerAdapter/implements SecurityFilterChain/g' {} +
# 4. 更新配置文件
sed -i '' 's/spring.security.oauth2.resourceserver.jwt.jwk-set-uri/spring.security.oauth2.resourceserver.jwt.jwk-set-uri/g' src/main/resources/application.yml
5.2.4 迁移验证
// 旧版本(3.5.x)
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/public/**").permitAll()
.anyRequest().authenticated();
}
}
// 新版本(4.1.0)
@Configuration
@EnableWebSecurity
public class SecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(authz -> authz
.requestMatchers("/public/**").permitAll()
.anyRequest().authenticated()
);
return http.build();
}
}
六、深度分析:与其他技术栈的对比
6.1 与Quarkus对比
| 对比维度 | Spring Boot 4.1.0 | Quarkus 3.x |
|---|---|---|
| 启动速度(JVM) | 2.8s | 1.2s |
| 启动速度(Native) | 0.12s | 0.02s |
| 内存占用(Native) | 58MB | 12MB |
| 生态成熟度 | ★★★★★ | ★★★★☆ |
| 学习曲线 | 中等 | 较陡 |
| 社区规模 | 超大 | 中等 |
| 企业采用 | 广泛 | 增长中 |
结论:Quarkus在启动速度和内存占用上仍有优势,但Spring Boot 4.1.0正在缩小差距。对于已有Spring生态的企业,迁移成本需权衡。
6.2 与Micronaut对比
| 对比维度 | Spring Boot 4.1.0 | Micronaut 4.x |
|---|---|---|
| AOT编译 | 支持 | 默认 |
| 反射使用 | 可选 | 极少 |
| 编译时检查 | 部分 | 全面 |
| 依赖注入 | 运行时 | 编译时 |
| 云原生支持 | 良好 | 优秀 |
结论:Micronaut在编译时优化上更激进,但Spring Boot的生态优势明显。
七、未来展望:5.0路线推测
7.1 短期方向(4.1.x系列)
GraalVM Native Image深度集成
- 简化反射配置
- 自动生成native hints
- 缩小与Quarkus的差距
虚拟线程全面支持
- Spring MVC虚拟线程默认启用
- WebFlux与虚拟线程融合
- 数据库连接池适配
可观测性增强
- OpenTelemetry 1.63+
- 分布式追踪标准化
- Metrics自动发现
7.2 长期方向(5.0路线推测)
| 方向 | 推测 |
|---|---|
| AOT编译默认化 | 构建时预编译成为默认方式 |
| Java版本提升 | 可能要求Java 27+ |
| 虚拟线程默认开启 | 全面拥抱Project Loom |
| 响应式融合 | Virtual Threads + Reactor混合模型 |
| AI集成 | Spring AI模块标准化 |
| 云原生默认 | Cloud Native Buildpacks作为默认构建工具 |
八、总结
Spring Boot 4.1.0不是一个"颠覆性"的版本,但它是4.x系列的"稳定之锚"。在遗留代码清理完成后,从4.1.0开始,Spring Boot进入了真正的性能和安全性优化阶段。
三个核心信号
- 🏆 Spring 4.x生态趋于稳定——Bug修复重点已从"功能兼容性"转向"安全加固和性能优化"
- 🏆 老旧技术加速淘汰——Derby退役、layertools移除、4.0废弃API全部清理
- 🏆 Java 25 + GraalVM是未来——文档中明确标注了Java 25 AOT缓存要求
升级建议
- 已在4.0.x:强烈建议升级到4.1.0,获取安全修复和性能优化
- 仍在3.x:可直接升级到4.1.0,跳过4.0.x,一步到位
- 新项目:直接使用4.1.0,拥抱Java 25和GraalVM
一句话总结
Spring Boot 4.1.0是2026年Java后端开发者必须关注的版本——它不是一个让你重新学习的版本,而是一个让你写得更稳、跑得更快、睡得更香的版本。
附录:完整依赖版本清单
| 依赖 | 版本 |
|---|---|
| Spring Framework | 7.0.8 |
| Spring Security | 7.1.0 |
| Spring Data | 2026.0.0 |
| Spring Kafka | 4.1.0 |
| Spring AMQP | 4.1.0 |
| Spring Session | 4.1.0 |
| Spring Integration | 7.1.0 |
| Spring Batch | 6.0.4 |
| Spring GraphQL | 2.0.4 |
| Spring gRPC | 1.1.0 |
| Hibernate | 7.4.1.Final |
| Tomcat | 11.0.22 |
| Jetty | 12.1.10 |
| Kotlin | 2.3.21 |
| Micrometer | 1.17.0 |
| Micrometer Tracing | 1.7.0 |
| OpenTelemetry | 1.62.0 |
| Reactor | 2025.0.6 |
| Kafka Client | 4.2.1 |
| Jackson | 2.21.4 / 3.1.4 |
| SLF4J | 2.0.18 |
| Logback | 1.5.34 |
| Netty | 4.2.15.Final |
| GraalVM Native Build Tools | 1.1.1 |
参考资源