What’s New in Spring 6? Key Changes for Jakarta EE Migration and Web Development
Spring 6 introduces major updates such as moving JSR‑330 and JSR‑250 annotations to Jakarta packages, deprecating ListenableFuture, requiring Hibernate 5.6.x with jakarta.persistence, updating servlet containers, altering controller detection, converting HttpMethod to a class, and adjusting Kotlin and RestTemplate APIs.
Core Changes
The
@Injectannotation from JSR‑330 is now located in the
jakarta.injectpackage. JSR‑250 annotations
@PostConstructand
@PreDestroyhave moved to
jakarta.annotation. Spring still detects these annotations under the
javaxpackage, including common usage in pre‑compiled binaries.
ListenableFuturehas been deprecated and fully replaced by
CompletableFuture(see issue 27780).
Data and Transactions
Due to the Jakarta EE migration, upgrade to Hibernate ORM 5.6.x and use the
hibernate-core-jakartaartifact, switching imports from
javax.persistenceto
jakarta.persistence. The corresponding Hibernate Validator version is 7.0.x, based on
jakarta.validation.
Web Applications
Upgrade to Tomcat 10, Jetty 11, or Undertow 2.2.14 and use the
undertow-servlet-jakartacomponent, changing imports from
javax.servletto
jakarta.servlet. Deprecated servlet components include Commons FileUpload, Tiles, and FreeMarker JSP support; use
StandardServletMultipartResolverfor file uploads and focus on a REST‑oriented architecture.
Spring MVC and Spring WebFlux no longer treat
@RequestMappingalone as a controller. Interface‑based AOP proxies may not apply; enable class‑based proxies or annotate interfaces with
@Controller(see issue 22154).
HttpMethodis now a class instead of an enum. Code using
EnumSet<HttpMethod>should switch to
Set<HttpMethod>and use
if‑elserather than
switch(see issue 27697).
Kotlin extension function
WebTestClient.ResponseSpec::expectBodynow returns
BodySpecinstead of
KotlinBodySpec. The
consumeWithmethod is no longer available. Spring 6.0 uses Kotlin 1.6, fixing bug KT‑5464.
RestTemplate’s
HttpComponentsClientHttpRequestFactorynow requires Apache HttpClient 5.
Java Architecture Diary
Committed to sharing original, high‑quality technical articles; no fluff or promotional content.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.