On November 16, 2022, Juergen Hoeller made the announcement that Spring Framework 6 will be officially released. Spring 6 is a major release, more than four years after the release of Spring 5. Let’s take a quick look at the exciting features in the Spring 6 release in this article.
JDK 17+ and Jakarta EE 9+ baseline
- Entire framework code base now based on Java 17 source level.
- Servlet, JPA, etc. migrated from javax to Jakarta namespace.
- Runtime compatibility with Jakarta EE 9 and Jakarta EE 10 APIs.
- Compatibility with the latest web servers: Tomcat 10.1, Jetty 11, Undertow 2.3.
- Early compatibility with virtual threads (previewed from JDK 19).
General core revisions
- Upgrade to ASM 9.4 and Kotlin 1.7.
- Complete CGLIB fork with support for capturing CGLIB generated classes.
- Full transition to AOT (Ahead-Of-Time Processing).
- First-class support for GraalVM native images.
Core
- By default, no
java.beans.Introspector
is required to determine the base bean properties. - Support for AOT processing in
GenericApplicationContext (refreshForAotProcessing)
. - Bean definition transformation based on pre-parsed constructors and factory methods.
- Support for early proxy class determination for AOP proxies and configuration classes.
PathMatchingResourcePatternResolver
scans using NIO and module path APIs, supporting class path scanning in GraalVM native images and Java module paths, respectively.DefaultFormattingConversionService
supports ISO-based defaultjava.time
type resolution.
Data access and transactions
- Support for scheduled JPA managed types (for inclusion in AOT processing).
- JPA support for Hibernate ORM 6.1 (maintains compatibility with Hibernate ORM 5.6).
- Upgraded to R2DBC 1.0 (includes R2DBC transaction definitions).
- Removed JCA CCI support.
Spring Messaging
- RSocket interface client based on the
@RSocketExchange
service interface. - Early support for Reactor Netty 2 based on Netty 5 Alpha.
- Support for Jakarta WebSocket 2.1 and its standard WebSocket protocol upgrade mechanism.
Web
- HTTP interface client based on the @HttpExchange service interface.
- Support for RFC 7807 problem details.
- Unified HTTP status code handling.
- Support for Jackson 2.14.
- Alignment with Servlet 6.0 (while retaining runtime compatibility with Servlet 5.0).
Spring MVC
- PathPatternParser used by default (ability to opt into PathMatcher).
- Remove deprecated Tiles and FreeMarker JSP support.
Spring WebFlux
- New PartEvent API for streaming multipart form uploads (both on client and server).
- New ResponseEntityExceptionHandler for customizing WebFlux exceptions and rendering RFC 7807 error responses.
- Flux return values for non-streaming types (List is no longer collected before writing).
- Early support for Reactor Netty 2 based on Netty 5 Alpha.
- JDK HttpClient integration with WebClient.
Observability
- Micrometer Observation is partially used in the Spring Framework. spring-web module now requires io.micrometer:micrometer-observation:1.10+ as a compiled dependency.
- RestTemplate and WebClient are detected as generating HTTP client request observations.
- Spring MVC can use the new
org.springframework.web.filter.ServerHttpObservationFilter
to detect HTTP server observations. - Spring WebFlux can use the new
org.springframework.web.filter.reactive.ServerHttpObservationFilter
to detect HTTP server observations. - For Flux and Mono’s Micrometer Context Propagation integration, return values from controller methods.
Testing
- Support for testing application contexts for AOT processing on JVM or in GraalVM native images.
- Integration with HtmlUnit 2.64 + request parameter handling.
- Servlet mockups (MockHttpServletRequest, MockHttpSession) are now based on Servlet API 6.0.
Ref
Reference https://waylau.com/new-features-and-enhancements-in-spring-framework-6/