문서의 이전 판입니다!
Spring Framework 5.3
Summary
- General Core Revision
- Core Container
- Data Access and Transactions
- Spring Messaging
- General Web Revision
- Spring MVC
- Spring WebFlux
- Testing
Descriptions
General Core Revision
- Upgrade to ASM 9.0 and Kotlin 1.4.
- Support for RxJava 3 in
ReactiveAdapterRegistrywhile support for RxJava 1.x is deprecated. - Improve GraalVM native support by removing unsupported features from native images.
- A
spring.spel.ignoreproperty 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/ifUniqueexplicitly ignores beans from currently inactive scopes.ApplicationListener.forPayload(Consumer)method for convenient programmaticPayloadApplicationEventhandling.CronExpression에서 Quartz 확장 지원:- the day-of-month field can use
Lto express the last day of the month,nLto express the nth-to-last day of the month, ornWto express the nearest weekday to day-of-month n. - the day-of-week field can use
DDDLto express the last day-of-week DDD in the month, orDDD#nto express the nth day-of-week DDD.
Data Access and Transactions
- New
spring-r2dbcsupport module, moving core R2DBC support and the reactiveR2dbcTransactionManagerinto the Spring Framework umbrella. - New
JdbcTransactionManagersubclass ofDataSourceTransactionManager, adding data access exception translation on commit. - New
DataClassRowMapperfor constructor-based binding support, including Kotlin/Lombok data classes and Java 14/15 record classes. - Support for
queryForStreamonJdbcTemplate, allowing for lazy iteration over a closeablejava.util.stream.Stream. - Configurable EntityManager/Session initializers on
Jpa/HibernateTransactionManagerandLocal(Container)EntityManagerFactoryBean. HibernateJpaVendorAdapterexposes Hibernate ORM 5.2+ conventions by default (e.g.SessionFactoryas 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. TransactionalApplicationListenerinterface with forPayload factory methods, callback support, and adapter classes for programmatic registration (as an alternative to@TransactionalEventListenerannotated methods).- Support for
@Transactionalsuspending functions (Kotlin Coroutines)
Spring Messaging
RSocketRequestersupport for the newRSocketClientas a result of which anRSocketRequestercan be obtained as an instance, i.e. without aMonowrapper or the need to connect first. A connection is transparently obtained as requests are made including support for reconnecting.RSocketRequestersupport for the newLoadbalanceRSocketClient.RSocketRequestersupport for metadataPush interactions.- The
preservePublishOrderoption for STOMP/WebSocket applications now works in combination with send buffer size and time limits. - Support for Kotlin multiplatform serialization (JSON only for now)
General Web Revision
- CORS configuration exposes a new
allowedOriginPatternsproperty for declaring a dynamic range of domains via wildcard patterns. RequestEntitysupports URI templates with variables.Jackson2ObjectMapperBuilderexposesConsumer<ObjectMapper>option for advanced customizations.DataBinderallows switching between direct field and bean property access during initialization. An example scenario is an@ControllerAdviceconfiguring direct field access by default globally with some controllers overriding that locally, via@InitBindermethod, to bean property access.- A
spring.xml.ignoreproperty 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". UrlPathHelperchecks theHttpServletMapping(Servlet 4.0) for a more efficient determination of the application path, see #25100.@ControllerAdvicecan handle exceptions from any handler type (i.e. not just@Controllerbut others likeHttpRequestHandler,HandlerFunction, etc) as long as it matches the handler mappings set onExceptionHandlerExceptionResolver.@ExceptionHandlercan target exception causes at any level of nesting.ForwardedHeaderFilterupdates the remote address/port from “Forwarded For” headers.- Add missing beans to
WebMvcConfigurationSupportin order to makeDispatcherServlet.properties(now lazily parsed) not needed for most use cases. - Support for Kotlin multiplatform serialization (JSON only for now)
Spring WebFlux
- New
DefaultPartHttpMessageReaderprovides a fully reactive message reader that converts a buffer stream into aFlux<Part> - New
PartHttpMessageWriterto write theFlux<Part>received from a client to a remote service. - New
WebClientconnector for Apache Http Components. WebClientandClientRequestprovide access to theClientHttpRequestand the native request. This is useful for customizing per-request options specific to the HTTP library.EncoderandDecoderimplementations for NettyByteBuf.ForwardedHeaderTransformerupdates the remote address/port from “Forwarded For” headers.@EnableWebFluxenables support for handlers of type WebSocketHandler.WebSocketSessionprovides access to the CloseStatus.WebHttpHandlerBuilderoption to decorate the entire WebFilter chain at the level of theHttpHandler.- More efficient direct path lookups for
@RequestMappingmethods that don't have any patterns or URI variables. ClientResponseperformance optimizations andmutate()method for efficient changes through a client filter oronStatushandler, 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
@Nestedtest classes.- This is a potentially breaking change, but the behavior can be reverted to override configuration from enclosing classes via the
@NestedTestConfigurationannotation, a JVM system property, or an entry in aspring.propertiesfile in the root of the classpath. - Consult the Javadoc for @NestedTestConfiguration and the reference manual for details.
- The
spring.test.constructor.autowire.modeproperty can now be set via a JUnit Platform configuration parameter to change the default@TestConstructorautowiring mode — for example, via thejunit-platform.propertiesfile. - A
PlatformTransactionManagerconfigured via theTransactionManagementConfigurerAPI now takes precedence over any transaction manager configured as a bean in theApplicationContextunless@Transactionalis 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 forpropagation = NOT_SUPPORTED— for example, to override a@Transactionaldeclaration from a composed annotation, on a superclass, etc. WebTestClientsupport for performing requests againstMockMvc. This enables the possibility to use the same API forMockMvctests and for full HTTP tests. See the updated section on testing in the reference documentation.WebTestClienthas 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
MockHttpServletResponseregarding character encoding and multipleContent-Languageheader values. - Major revision of MockMVC Kotlin DSL to support multiple matchers