{{tag>[spring spring-framwork]}} ====== Spring Framework 5.3 ====== [[https://github.com/spring-projects/spring-framework/wiki/What%27s-New-in-Spring-Framework-5.x]] ===== 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 ''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. * ''CronExpression''에서 Quartz 확장 지원: * 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 [[https://docs.spring.io/spring-framework/docs/current/reference/html/languages.html#kotlin-multiplatform-serialization|Kotlin multiplatform serialization]] (JSON only for now) === General Web Revision === * CORS 설정은 와일드카드 패턴을 통하여 도메인의 동적 범위를 선언하기 위한 새로운 속성인 ''allowedOriginPatterns''을 노출합니다.. * ''RequestEntity''은 변수와 함께 URI 템플릿을 지원합니다.. * ''Jackson2ObjectMapperBuilder'' exposes ''Consumer'' 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 [[https://spring.io/blog/2020/06/30/url-matching-with-pathpattern-in-spring-mvc|"URL Matching with PathPattern in Spring MVC"]]. * ''UrlPathHelper'' checks the ''HttpServletMapping'' (Servlet 4.0) for a more efficient determination of the application path, see [[https://github.com/spring-projects/spring-framework/issues/25100|#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 [[https://docs.spring.io/spring-framework/docs/current/reference/html/languages.html#kotlin-multiplatform-serialization|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'' * New ''PartHttpMessageWriter'' to write the ''Flux'' received from a client to a remote service. * New ''WebClient'' connector for [[https://hc.apache.org/httpcomponents-client-5.0.x/|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 [[https://docs.spring.io/spring-framework/docs/current/reference/html/languages.html#kotlin-multiplatform-serialization|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 [[https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/test/context/NestedTestConfiguration.html|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 [[https://docs.spring.io/spring/docs/current/spring-framework-reference/testing.html#spring-mvc-test-client|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 ===== Dependencies =====