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.

macrozheng
macrozheng
macrozheng
What’s New in Spring Framework 6.0? Key Changes and Migration Guide

Java EE Migration

Oracle donated Java EE to the Eclipse Foundation; the name changed to Jakarta EE, and package prefixes changed from javax to jakarta, e.g., javax.persistencejakarta.persistence.

Core Containers

JSR‑250 and JSR‑330 packages are moving to Jakarta EE.

Persistence Layer

Jakarta EE persistence specifications are updated; javax.persistence and jakarta.validation are 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-jakarta are 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 @RequestMapping as a controller. After 6.0, a class must be annotated with @Controller or @RestController. The previous AOP‑based proxy mechanism is disabled; enable class‑based proxies for such controllers.

/** 6.0之前
 * @author felord.cn
 */
@Component
@RequestMapping("/foo")
public class FooController {
    @GetMapping("/hello")
    public Map<String, String> hello() {
        return Collections.singletonMap("hello", "world");
    }
}
After 6.0, a controller must be annotated with @Controller or @RestController .

HttpMethod

Before 6.0, HttpMethod was a Java enum. It has been replaced by a final class implementing Comparable and Serializable.

public enum HttpMethod {
    GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
    // resolve and matches methods omitted for brevity
}
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
}

Other Frontiers

The second milestone of Spring Framework 6.0 and the first milestone of Spring Boot 3.0 are expected in January 2022.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

backend-developmentServletSpring Frameworkjakarta-eeHttpMethod
macrozheng
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.