Skip to content

build: upgrade all dependencies to latest (Spring Boot 2.5 to 4.1) - #41

Merged
houko merged 6 commits into
mainfrom
chore/upgrade-all-dependencies
Sep 9, 2026
Merged

build: upgrade all dependencies to latest (Spring Boot 2.5 to 4.1)#41
houko merged 6 commits into
mainfrom
chore/upgrade-all-dependencies

Conversation

@houko

@houko houko commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Upgrades every dependency in the project to its latest release. This is not a version-number bump — Spring Boot 2.5.12 to 4.1.1 crosses two major versions, so it carries the full javax to jakarta migration, the Jackson 2 to 3 switch, and the removal of several libraries that have no Spring Boot 4 successor.

Dependency versions

Dependency Before After
Spring Boot 2.5.12 4.1.1
JDK baseline 11 21
springfox-swagger 2.2.2 springdoc-openapi 3.1.1
mysql-connector mysql:mysql-connector-java 8.0.28 com.mysql:mysql-connector-j 26.7.0
dom4j dom4j:dom4j 1.6.1 org.dom4j:dom4j 2.2.0
fastjson com.alibaba:fastjson [1.2.31,) com.alibaba.fastjson2:fastjson2 2.0.65
Apache POI 3.17 5.5.1
mybatis-spring-boot 1.1.1 4.1.0
jsoup 1.9.2 (effective) 1.23.2
commons-io 2.7 2.22.0
commons-lang3 3.5 3.20.0
lombok 1.18.14 1.18.48
slf4j 1.7.21 2.0.19
zxing 3.2.1 / 3.3.3 3.5.4
maven-compiler-plugin 3.5.1 3.16.0
maven-surefire-plugin 2.19.1 3.6.0
maven-source-plugin 3.2.0 3.4.0
actions/checkout v3 v7
github/codeql-action v2 v4

Jackson, Hibernate, JUnit, Tomcat, Thymeleaf and the rest are now managed by the spring-boot-dependencies BOM rather than being pinned by hand.

Pre-existing bugs fixed along the way

  • jsoup.version was declared twice in the parent POM. The second declaration (1.9.2) silently overrode the first (1.14.2), so Bump jsoup from 1.10.1 to 1.14.2 #32's jsoup upgrade never actually took effect — the build has been resolving a 2016 release this whole time.
  • Open-ended version ranges. fastjson used [1.2.31,) and commons-fileupload used [1.3.3,), which makes builds non-reproducible and silently pulls whatever is newest at build time. Both are gone now.
  • spring.redis.pool.* had been dead config since Spring Boot 2.0. The correct key is spring.data.redis.lettuce.pool.*; the old keys were being ignored entirely.
  • The in-memory security user could not log in. .password("test") with no PasswordEncoder throws IllegalArgumentException: There is no PasswordEncoder mapped for the id "null" on any Spring Security 5+ login attempt. Now {noop}test, which preserves the plaintext-demo intent and actually works.

Migration details

javax to jakarta — 49 imports across persistence, servlet, mail and websocket. javax.sql, javax.net and javax.swing are JDK packages and were correctly left alone.

Spring Boot 4 module split@EntityScan, DataSourceAutoConfiguration and HibernateJpaAutoConfiguration all moved out of org.springframework.boot.autoconfigure.* into their own modules.

Jackson 2 to 3 — Spring Boot 4 defaults to Jackson 3 under the tools.jackson package. JsonSerializer became ValueSerializer, SerializerProvider became SerializationContext, and serialize no longer declares a checked exception. Jackson 2.21.5 is still on the classpath because swagger-core needs it; both are BOM-managed and coexist by design.

Spring SecurityWebSecurityConfigurerAdapter was removed in Spring Security 6. Replaced with a SecurityFilterChain bean plus a UserDetailsService bean.

springfox to springdoc — springfox has been unmaintained since 2020 and does not support jakarta. The four Docket + ApiInfo configurations became GroupedOpenApi + OpenAPI beans, preserving the original basePackage grouping. 32 annotation usages moved to OpenAPI 3: @Api to @Tag, @ApiOperation to @Operation, @ApiImplicitParam to @Parameter, @ApiModelProperty to @Schema, @ApiIgnore to @Hidden.

Apache POI 5 — the HSSFCell.CELL_TYPE_* int constants became the CellType enum, and HSSFDateUtil was folded into DateUtil.

Dropped

knife4j (formerly swagger-bootstrap-ui). Its latest release, 4.5.0, still targets Spring Boot 3.0.4 and springdoc 2.x, so it cannot run under Spring Boot 4. The /doc.html UI it provided is gone; springdoc's own Swagger UI at /swagger-ui.html remains and is verified working below.

commons-fileupload. Not referenced by any source file, and it is built on javax.servlet with no drop-in jakarta replacement under the same coordinates.

junit4. Superseded by JUnit 5 via spring-boot-starter-test. The project's single test was migrated.

Verification

mvn clean install — all 17 modules pass:

[INFO] BUILD SUCCESS

Runtime smoke test on the order module (the one module needing no external services), confirming the springdoc rewiring actually works rather than merely compiling:

Starting OrderMain using Java 21.0.2
Starting Servlet engine: [Apache Tomcat/11.0.24]
Started OrderMain in 1.438 seconds
:: Spring Boot ::                (v4.1.1)

GET /v3/api-docs/order returns a well-formed OpenAPI 3.1.0 document with the migrated annotations intact — tag, summary, description, the path parameter with its description and required flag, and both declared error responses. @Hidden correctly keeps the / redirect out of the spec. GET /swagger-ui.html returns 302 to /swagger-ui/index.html, which returns 200.

Note

Tests remain globally disabled by <skipTests>true</skipTests> in the parent POM, unchanged from before. The single existing test (RabbitMqTests) has no @SpringBootTest, so its @Autowired field is null and it would NPE if ever enabled — pre-existing, left alone as out of scope here.

Security alerts closed

All 7 open Dependabot alerts on the default branch are resolved by this upgrade:

Severity Package CVE Resolution
critical io.springfox:springfox-swagger-ui CVE-2019-17495 springfox removed entirely
high commons-io:commons-io CVE-2024-47554 2.7 to 2.22.0
high mysql:mysql-connector-java CVE-2023-22102 replaced by com.mysql:mysql-connector-j 26.7.0
high org.jsoup:jsoup CVE-2021-37714 1.9.2 to 1.23.2
medium org.apache.commons:commons-lang3 CVE-2025-48924 3.5 to 3.20.0
medium org.apache.poi:poi CVE-2019-12415 3.17 to 5.5.1
medium org.jsoup:jsoup CVE-2022-36033 1.9.2 to 1.23.2

The two jsoup entries are worth calling out: #32 bumped jsoup to 1.14.2 and was merged, but the duplicate jsoup.version property meant the build kept resolving 1.9.2, so CVE-2021-37714 was never actually fixed. Removing the duplicate is what closes it.

将 spring-boot-starter-parent 的伪导入换成 spring-boot-dependencies BOM 导入,
统一由 BOM 管理 spring / jackson / hibernate / junit 等版本。

- spring boot 2.5.12 -> 4.1.1, JDK 11 -> 21
- springfox-swagger 2.2.2 -> springdoc-openapi 3.1.1 (springfox 已停止维护且不支持 jakarta)
- mysql:mysql-connector-java 8.0.28 -> com.mysql:mysql-connector-j 26.7.0 (groupId 变更)
- dom4j:dom4j 1.6.1 -> org.dom4j:dom4j 2.2.0 (groupId 变更)
- com.alibaba:fastjson -> com.alibaba.fastjson2:fastjson2 2.0.65
- poi 3.17 -> 5.5.1, jsoup -> 1.23.2, commons-io -> 2.22.0, commons-lang3 -> 3.20.0
- lombok -> 1.18.48, slf4j -> 2.0.19, zxing -> 3.5.4, mybatis-spring-boot -> 4.1.0
- maven 插件: compiler 3.5.1 -> 3.16.0, surefire 2.19.1 -> 3.6.0, source 3.2.0 -> 3.4.0

同时修掉三个既有问题:
- jsoup.version 属性重复定义, 后一处 1.9.2 覆盖了前一处 1.14.2, 导致之前的 jsoup 升级实际未生效
- fastjson 和 commons-fileupload 使用开区间版本 [x,), 构建不可复现, 现已全部钉死
- 移除未被任何代码引用且不兼容 jakarta 的 commons-fileupload, 以及被 spring-boot-starter-test 取代的 junit4

knife4j (swagger-bootstrap-ui 的后继) 最新版 4.5.0 仍锁定 spring boot 3.0.4 与 springdoc 2.x,
无法与 spring boot 4 共存, 故移除, 改用 springdoc 自带的 swagger-ui。
spring boot 3 起 javax.* 全面迁移到 jakarta.*, 同时 spring boot 4 拆分了
autoconfigure 模块并默认改用 jackson 3, 一并适配。

- javax.persistence/servlet/mail/websocket -> jakarta.*  (javax.sql / javax.net / javax.swing 属 JDK 自带, 保持不变)
- @EntityScan -> org.springframework.boot.persistence.autoconfigure
- DataSourceAutoConfiguration -> org.springframework.boot.jdbc.autoconfigure
- HibernateJpaAutoConfiguration -> org.springframework.boot.hibernate.autoconfigure
- jackson 2 -> 3: com.fasterxml.jackson.databind.JsonSerializer -> tools.jackson.databind.ValueSerializer,
  SerializerProvider -> SerializationContext, serialize 不再抛受检异常
- poi 5: HSSFCell.CELL_TYPE_* 常量 -> CellType 枚举, HSSFDateUtil -> DateUtil
- fastjson -> fastjson2 (JSON / JSONObject 用法一致, 仅换包)
- security: WebSecurityConfigurerAdapter 已被移除, 改用 SecurityFilterChain + UserDetailsService Bean。
  内存用户密码补上 {noop} 前缀 —— 原先未指定编码器, 在 spring security 5 之后登录时会直接抛异常
- springfox Docket + ApiInfo -> springdoc GroupedOpenApi + OpenAPI Bean, 保留原有的 basePackage 分组范围
- swagger 注解升级到 OpenAPI 3: @Api -> @tag, @apioperation -> @operation,
  @ApiImplicitParam -> @parameter, @ApiModelProperty -> @Schema, @ApiIgnore -> @hidden
- 唯一的测试从 JUnit 4 迁移到 JUnit 5
这些配置编译期不会报错, 但在 spring boot 4 上会静默失效或直接启动失败。

- spring.redis.* -> spring.data.redis.*  (spring boot 2.4 起改名)
- spring.redis.pool.* -> spring.data.redis.lettuce.pool.*  (原写法是 spring boot 1.x 的名字, 早已失效)
- org.hibernate.dialect.MySQL5Dialect -> MySQLDialect  (MySQL5Dialect 在 hibernate 6 已被移除, 当前为 7.4.5)
- actions/checkout v3 -> v7, github/codeql-action v2 -> v4  (v2 已停止服务)
- 新增 actions/setup-java 固定 JDK 21, 不再依赖 runner 镜像的默认 JDK,
  否则 spring boot 4 所需的 JDK 17+ 无法保证
- travis: oraclejdk11 -> openjdk21, dist trusty -> jammy
- Readme 环境说明与更新日志同步到本次升级
仓库此前没有任何构建 CI: 唯一的 workflow 是 CodeQL(安全扫描), 而 Readme 上的
Travis 徽章指向 travis-ci.org —— 该站 2021 年 6 月已关停, 徽章长期是死链。
也就是说没有任何 CI 会去编译这个项目。

新增 build workflow, 在 JDK 21(编译目标) 和 25(当前 LTS) 上跑 mvn clean install,
并把 Readme 徽章换成该 workflow 的状态。

保留 .travis.yml 未动(本次已同步更新其 jdk 版本), 是否弃用 travis 由仓库主人决定。
该 workflow 自 2022 年加入以来一次都没运行过, 加上 workflow_dispatch 便于手动验证和排查。
@houko
houko merged commit f01e383 into main Sep 9, 2026
2 checks passed
@houko
houko deleted the chore/upgrade-all-dependencies branch September 9, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant