spring-boot 2.5.x 升级到 2.7.x 关键事项

538 阅读1分钟

spring-boot 各版本的维护支持时间

spring.io/projects/sp…

spring-boot 2.5.x 升级到 2.6.x

github.com/spring-proj…

Spring Boot 2.4 中废弃的类、方法,属性已移除

在升级前,确保没有调用废弃的方法,使用废弃的类或属性。

SpringMVC 默认路径配置策略调整为 PathPattern

可以通过属性配置,切换为 ant-path-matcher 【推荐方案,这样升级更快】 spring.mvc.pathmatch.matching-strategy=ant-path-matcher

PathPattern 比 AntPathMatcher 更严格。 AntPathMatcher 策略中,authorizeRequests.mvcMatchers("hello").permitAll() 支持 /hello
但是 PathPattern 不行,需要改写为 authorizeRequests.mvcMatchers("/hello").permitAll()

默认不允许循环引用

可以通过属性设置【不推荐,循环引用如果存在,应该修改】

Elasticsearch 属性设置调整

参考文档进行替换

github.com/spring-proj…

Kafka 3.0

springb-boot 2.6 将 kafka 升级到  3.0,调整了默认的投递策略

spring-boot 2.6.x 升级到 2.7.x

github.com/spring-proj…

H2 database 升级到 2.x(不兼容 1.x 版本)

www.h2database.com/html/migrat…

jOOQ 版本兼容问题

目前开源的版本 jOOQ 不支持 Java 8 + H2 2.x 版本,如果使用 java 11, jooq.version 版本升级到 3.16。

如果使用 java 8 ,需要购买 JOOQ 付费版本或H2 迁移到其他数据库,或降级 H2 到 1.4.x、

WebSecurityConfigurerAdapter 被废弃

Spring Boot 2.7 升级到 Spring Security 5.7,后者已弃用 WebSecurityConfigurerAdapter。