The Spring Framework team have announced the that Spring Framework 5.3 is generally available from repo.spring.io as well as Maven Central!
This release of the framework requires JDK 8 or a higher version and specifically embraces JDK 15 as the latest OpenJDK release, e.g. with binding support for record classes.
The various features included in this release are as follows:
General Core Revision
- Upgrade to ASM 9.0 and Kotlin 1.4.
- Support for RxJava 3 in ReactiveAdapterRegistry while support for RxJava 1.x is deprecated.
- Improve GraalVM native support by removing unsupported features from native images.
- A spring.spel.ignore property to remove SpEL support for applications not using it.
Core Container
- Binding support for Java 14/15 record classes and similarly styled constructors/accessors.
- ObjectProvider.ifAvailable/ifUnique explicitly ignores beans from currently inactive scopes.
- ApplicationListener.forPayload(Consumer) method for convenient programmatic PayloadApplicationEvent handling.
- Support for Quartz extensions in CronExpression:
- the day-of-month field can use L to express the last day of the month, nL to express the nth-to-last day of the month, or nW to express the nearest weekday to day-of-month n.
- the day-of-week field can use DDDL to express the last day-of-week DDD in the month, or DDD#n to express the nth day-of-week DDD.
Data Access and Transactions
- New spring-r2dbc support module, moving core R2DBC support and the reactive R2dbcTransactionManager into the Spring Framework umbrella.
- New JdbcTransactionManager subclass of DataSourceTransactionManager, adding data access exception translation on commit.
- New DataClassRowMapper for constructor-based binding support, including Kotlin/Lombok data classes and Java 14/15 record classes.
- Support for queryForStream on JdbcTemplate, allowing for lazy iteration over a closeable java.util.stream.Stream.
- Configurable EntityManager/Session initializers on Jpa/HibernateTransactionManager and Local(Container)EntityManagerFactoryBean.
- HibernateJpaVendorAdapter exposes Hibernate ORM 5.2+ conventions by default (e.g. SessionFactory as EMF vendor interface).
- Transaction definitions may declare custom labels now (for use in custom transaction managers).
- Support for timeout values with ${…} placeholders in transaction definitions.
- TransactionalApplicationListener interface with forPayload factory methods, callback support, and adapter classes for programmatic registration (as an alternative to @TransactionalEventListener annotated methods).
- Support for @Transactional suspending functions (Kotlin Coroutines)
Spring Messaging
- RSocketRequester support for the new RSocketClient as a result of which an RSocketRequester can be obtained as an instance, i.e. without a Mono wrapper or the need to connect first. A connection is transparently obtained as requests are made including support for reconnecting.
- RSocketRequester support for the new LoadbalanceRSocketClient.
- RSocketRequester support for metadataPush interactions.
- The preservePublishOrder option for STOMP/WebSocket applications now works in combination with send buffer size and time limits.
- Support for Kotlin multiplatform serialization (JSON only for now)
- StompBrokerRelayMessageHandler can be configured with a Taskscheduler in order to send heartbeats to the broker in lieu of messages with a non-broker destination. This can help for clients that send heartbeats only when no other messages are sent.
General Web Revision
- CORS configuration exposes a new allowedOriginPatterns property for declaring a dynamic range of domains via wildcard patterns.
- RequestEntity supports URI templates with variables.
- Jackson2ObjectMapperBuilder exposes Consumer<ObjectMapper> option for advanced customizations.
- DataBinder allows switching between direct field and bean property access during initialization. An example scenario is an @ControllerAdvice configuring direct field access by default globally with some controllers overriding that locally, via @InitBinder method, to bean property access.
- A spring.xml.ignore property to remove XML support for applications not using it, including related converters and codecs.
Spring MVC
- Efficient URL matching with parsed PathPattern’s in Spring MVC; see “URI Patterns” in the “Web Servlet” section of the documentation and blog post “URL Matching with PathPattern in Spring MVC“.
- UrlPathHelper checks the HttpServletMapping (Servlet 4.0) for a more efficient determination of the application path, see #25100.
- @ControllerAdvice can handle exceptions from any handler type (i.e. not just @Controller but others like HttpRequestHandler, HandlerFunction, etc) as long as it matches the handler mappings set on ExceptionHandlerExceptionResolver.
- @ExceptionHandler can target exception causes at any level of nesting.
- ForwardedHeaderFilter updates the remote address/port from “Forwarded For” headers.
- Add missing beans to WebMvcConfigurationSupport in order to make DispatcherServlet.properties (now lazily parsed) not needed for most use cases.
- Support for Kotlin multiplatform serialization (JSON only for now)
Spring WebFlux
- New DefaultPartHttpMessageReader provides a fully reactive message reader that converts a buffer stream into a Flux<Part>
- New PartHttpMessageWriter to write the Flux<Part> received from a client to a remote service.
- New WebClient connector for Apache Http Components.
- WebClient and ClientRequest provide access to the ClientHttpRequest and the native request. This is useful for customizing per-request options specific to the HTTP library.
- Encoder and Decoder implementations for Netty ByteBuf.
- ForwardedHeaderTransformer updates the remote address/port from “Forwarded For” headers.
- @EnableWebFlux enables support for handlers of type WebSocketHandler.
- WebSocketSession provides access to the CloseStatus.
- WebHttpHandlerBuilder option to decorate the entire WebFilter chain at the level of the HttpHandler.
- More efficient direct path lookups for @RequestMapping methods that don’t have any patterns or URI variables.
- ClientResponse performance optimizations and mutate() method for efficient changes through a client filter or onStatus handler, see #24680.
- Support for Kotlin multiplatform serialization (JSON only for now)
Testing
- The Spring TestContext Framework is now built and tested against JUnit Jupiter 5.7, JUnit 4.13.1, and TestNG 7.3.0.
- Test-related annotations on enclosing classes are now inherited by default for JUnit Jupiter @Nested test classes.
- This is a potentially breaking change, but the behavior can be reverted to override configuration from enclosing classes via the @NestedTestConfiguration annotation, a JVM system property, or an entry in a spring.properties file in the root of the classpath.
- Consult the Javadoc for @NestedTestConfiguration and the reference manual for details.
- The spring.test.constructor.autowire.mode property can now be set via a JUnit Platform configuration parameter to change the default @TestConstructor autowiring mode — for example, via the junit-platform.properties file.
- A PlatformTransactionManager configured via the TransactionManagementConfigurer API now takes precedence over any transaction manager configured as a bean in the ApplicationContext unless @Transactional is configured with a qualifier for the explicit transaction manager to use in tests.
- Test-managed transactions may now be disabled via @Transactional(propagation = NEVER) in addition to the existing support for propagation = NOT_SUPPORTED — for example, to override a @Transactional declaration from a composed annotation, on a superclass, etc.
- WebTestClient support for performing requests against MockMvc. This enables the possibility to use the same API for MockMvc tests and for full HTTP tests. See the updated section on testing in the reference documentation.
- WebTestClient has improved support for asserting all values of a header.
- Multipart data matchers in the client-side REST test support for the RestTemplate.
- HtmlUnit integration for Spring MVC Test supports file upload parameters.
- Minor enhancements to MockHttpServletResponse regarding character encoding and multiple Content-Language header values.
- Major revision of MockMVC Kotlin DSL to support multiple matchers
The spring boot 2.4 and also Spring Boot 2.5 which will release next year will be based on this framework generation.
This version of the framework is not the recommended upgrade for all 5.x and 4.x users. Spring Framework 5.3 also has an extended maintainence phase until 2024.
Click here to get to know about upgrading to 5.3
Source:
1.) Spring
2.) Github
1 Comment
[…] Article:What’s new in Springboot 5.3?Top Open Source Software Development […]