What’s New in Spring Framework 6.0? Key Changes and Migration Guide
Spring Framework 6.0 milestone introduces Jakarta EE migration, updates core containers and persistence, upgrades servlet baselines, removes deprecated APIs, changes controller scanning rules, and replaces the HttpMethod enum with a class, while previewing the upcoming Spring Boot 3.0 release.
Java EE Migration
Oracle donated Java EE to the Eclipse Foundation; the name changed to Jakarta EE, and package prefixes changed from
javaxto
jakarta, e.g.,
javax.persistence→
jakarta.persistence.
Core Containers
JSR‑250 and JSR‑330 packages are moving to Jakarta EE.
Persistence Layer
Jakarta EE persistence specifications are updated;
javax.persistenceand
jakarta.validationare implemented by Hibernate ORM 5.6.x and Hibernate Validator 7.0.x.
Web Applications
Servlet Middleware Baseline
Due to Jakarta EE migration, servlet containers are upgraded. Tomcat 10, Jetty 11, or Undertow 2.2.14 with
undertow-servlet-jakartaare the baseline.
Removal of Deprecated APIs
Commons FileUpload component removed.
Tiles layout components such as FreeMarker and JSP are no longer supported; Spring now focuses on Restful Web architecture.
Controller Scanning Changes
Spring MVC and Spring WebFlux no longer treat a class annotated only with
@RequestMappingas a controller. After 6.0, a class must be annotated with
@Controlleror
@RestController. The previous AOP‑based proxy mechanism is disabled; enable class‑based proxies for such controllers.
<code>/** 6.0之前
* @author felord.cn
*/
@Component
@RequestMapping("/foo")
public class FooController {
@GetMapping("/hello")
public Map<String, String> hello() {
return Collections.singletonMap("hello", "world");
}
}
</code>After 6.0, a controller must be annotated with @Controller or @RestController .
HttpMethod
Before 6.0,
HttpMethodwas a Java enum. It has been replaced by a final class implementing
Comparableand
Serializable.
<code>public enum HttpMethod {
GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
// resolve and matches methods omitted for brevity
}
</code> <code>public final class HttpMethod implements Comparable<HttpMethod>, Serializable {
public static final HttpMethod GET = new HttpMethod("GET");
public static final HttpMethod HEAD = new HttpMethod("HEAD");
public static final HttpMethod POST = new HttpMethod("POST");
public static final HttpMethod PUT = new HttpMethod("PUT");
// other constants and implementation omitted for brevity
}
</code>Other Frontiers
The second milestone of Spring Framework 6.0 and the first milestone of Spring Boot 3.0 are expected in January 2022.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
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.