跪拜 Guibai
← All articles
Backend · Java · Interview

Java 25 and Spring Boot 4 Migration: A Field Guide to the Silent Breakages

By Cosolar ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Spring Boot 4 and Java 25 are landing in production, and the upgrade is full of silent behavior changes that compile cleanly and break at runtime - Flyway no longer auto-configures, Jackson 3 flips date formats, and several JEPs get misattributed to the wrong JDK version. Teams upgrading now need this kind of verification-first checklist to avoid weeks of debugging.

Summary

A developer's week-long upgrade of two services from Java 21 to 25 and Spring Boot 3.5 to 4.1 looks smooth on the surface - compilation passes, startup succeeds - but the real cost is in runtime behavior changes that don't announce themselves. The article's central discipline is changing one variable at a time: first JDK, then Boot, so any regression can be attributed to one layer. That decision alone saved days of debugging.

On the JDK side, the upgrade yields real benefits like Scoped Values becoming final (with a breaking change in `orElse`) and virtual threads no longer pinning, but the traps are in compatibility: `sun.misc.Unsafe` deprecation, the removal of `--illegal-access`, and a pile of JEPs that online articles misattribute to JDK 25 when they actually belong to JDK 26. The Boot 4 upgrade is dominated by modularization: auto-configuration splits into per-starter modules, which means Flyway stops running unless you switch to `spring-boot-starter-flyway`, and Jackson 3's immutable `JsonMapper` changes date serialization to ISO-8601 by default, silently breaking contracts with downstream systems.

The article offers a practical verification checklist: diff real API responses before and after, verify database migrations at three levels, search for removed keywords, and review OpenRewrite's automated edits rather than trusting them. It also maps version coupling for Spring AI (2.0 requires Boot 4.0/4.1; 2.1 requires 4.2) and warns against relying on second-hand support matrices.

Takeaways
— JDK 25 GA'd on September 16, 2025; Boot 4.0 on November 20, 2025; Boot 4.1 on June 10, 2026; Spring AI 2.0 on June 12, 2026.
— Boot 4 still supports Java 17 as the minimum; Java 25 is first-class support, not a requirement.
— Scoped Values (JEP 506) became final in JDK 25, and `ScopedValue.orElse` no longer accepts `null`.
— Compact Object Headers (JEP 519) and Generational Shenandoah (JEP 521) are production features in JDK 25 but not enabled by default; you must add explicit JVM flags.
— In Boot 4, Flyway auto-configuration moved from `flyway-core` to `spring-boot-starter-flyway`; without the starter, Flyway silently never runs.
— Jackson 3 defaults to ISO-8601 date strings and uses the immutable `JsonMapper`; custom `new ObjectMapper()` instances change their output format.
— Lombok adds JDK 25 support starting at v1.18.40; JDK 24 support arrived in v1.18.38.
— JEP 500, 504, 516, 517, 522, 525, and 526 belong to JDK 26, not JDK 25; structured concurrency is still the fifth preview in 25.
— Spring AI 2.0 targets Boot 4.0/4.1 and Framework 7; Spring AI 2.1 requires Boot 4.2.
Conclusions

The upgrade's true cost is in silent behavior changes, not compile errors; the author's habit of diffing real API responses before and after is the only reliable way to catch them.

Splitting the JDK and Boot upgrades into separate commits isolates variables so precisely that any regression points to one layer; this should be a standard practice for major framework migrations.

Version misinformation is rampant: three widely repeated claims (Boot 4 requires Java 21, JEP 517 in JDK 25, structured concurrency final in 25) all turned out false when checked against official sources, underscoring that primary documents beat blog posts.

Boot 4's modularization is a long-overdue haircut for autoconfigure bloat, but it pushes complexity onto developers who must now know exactly which starter provides which behavior, or face silent gaps like Flyway.

Concepts & terms
Scoped Values (JEP 506)
A Java mechanism for sharing immutable data within a thread's execution context, similar to thread-local but with a lifetime scope; it became final in JDK 25 with a breaking change in the API.
Compact Object Headers (JEP 519)
A JVM optimization that shrinks the memory footprint of object headers to help with cache density; available as a production feature in JDK 25 but not enabled by default.
Generational Shenandoah (JEP 521)
A garbage collection mode for the Shenandoah collector that splits the heap into young and old generations to improve pause times; production feature in JDK 25 but off by default.
spring-boot-starter-classic
A Spring Boot 4 transition artifact that restores broad auto-configuration coverage from older versions, letting a project get a green build before gradually migrating to modular starters.
From the discussion
Featured comments
MR_H

Did you use an agent to assist with this work?

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗