파란하늘의 지식창고
Published 2020. 12. 1. 15:10
Upgrading to Spring Framework 5.3 Study/Java
반응형

Upgrading to Spring Framework 5.x

Upgrading to Spring Framework 5.x의 5.3 버전에 대한 내용을 번역한 글입니다.

spring-projects/spring-framework

 

spring-projects/spring-framework

Spring Framework. Contribute to spring-projects/spring-framework development by creating an account on GitHub.

github.com

Upgrading to Version 5.3

Third-Party APIs and Libraries

Kotlin의 경우

  • Kotlin 지원이 1.4로 업그레이드되었으며 여전히 Kotlin 1.3+과 호환됩니다.
  • Coroutione 지원을 위해 Kotlin Coroutines 1.4 (Kotlin 1.4 기반) 이상이 필요합니다.
  • kotlin scripting을 위해 kotlin 1.4 사용자는 kotlin-scripting-jsr-embeddable 대신 kotlin-scripting-jsr223 dependency를 명시해야 합니다.

Hibernate 지원은 ORM 5.3.x에 초점을 맞춘 Hibernate ORM 5.2+ 기준선으로 업그레이드되었습니다.
Hibernate Search는 Spring Framework 5.3 JPA 호환성을 위해 5.11.6으로 업그레이드되어야 합니다.
Hibernate JIRA를 참조하세요.

jackson 지원은 현재 jackson 2.9에서 2.12까지 지원하며 일반적으로 각 분기의 최신 release를 포함합니다.

Groovy 3.0은 현재 공식적으로 지원되는 버전이며 Groovy 2.x 지원은 단계적으로 중단됩니다.

RxJava 1.x는 더 이상 지원되지 않습니다. RxJava 2.x가 새로운 기준이며 3.x도 이제 지원됩니다.

JCA CCI 지원은 특정 data access API(또는 대안이 없는 경우 기본 CCI 사용)를 위해 deprecated 되었습니다.

여러 remoting technologies가 직접 대체되지 않고 더 이상 사용되지 않습니다. (Hessian, RMI, HTTP Invoker, JMS Invoker)

MimeMessageHelper는 더 이상 기본적으로 첨부 파일의 파일 이름을 명시적으로 encoding 하지 않고 JavaMail 1.5로 정렬되었습니다.

Core Container

properties-based definition format과 이를 기반으로 하는 모든 support class (예: PropertiesBeanDefinitionReader, JdbcBeanDefinitionReaderResourceBundleViewResolver)는 Spring의 common bean definition format 또는/혹은 custom reader implementation을 위해 사용되지 않습니다.

InstantiationAwareBeanPostProcessorAdapter는 이제 deprecated 되었습니다.
(Smart)InstantiationAwareBeanPostProcessor의 기존 default method에 대해 더 이상 사용되지 않습니다.

BeanNameAutoProxyCreator는 이제 custom TargetSourceCreator에 적용될 때 구성된 beanNames list를 따릅니다.
결과적으로 BeanNameAutoProxyCreator는 더 이상 beanNames list로 구성된 이름과 일치하지 않는 bean을 proxy 처리하지 않습니다.
gh-24915를 참조하세요.

@EventListener method가 이제 Ordered.LOWEST_PRECEDENCE의 암묵적 order value를 사용합니다.
이제 transaction synchronization과 @TransactionalEventListener method와 함께 정렬이 됩니다.
만약 custom ordering이 필요한 경우 @Order value를 모든 listener method에서 일관되게 선언하십시오.

Data Access and Transactions

Object[] argument를 사용하는 몇몇 JdbcTemplate signature가 기존 varargs equivalents를 위해 deprecated 되었습니다.

HibernateJpaVendorAdaptorEntitymanager(Factory)Session(Factory)를 default extension interface로 노출합니다. (Hibernate ORM 5.2 + 이후)

Reactive transaction은 Reactive Stream cancel signal을 일관되게 roll back 하여 common datastore transaction에 대한 partial commit을 방지합니다.

Web Applications

allowCredential이 true로 설정된 CORS configuartion에서 이제 allowedOrigins를 통해 허용하거나 또는 새로 추가된 allowedOriginPatterns를 사용할 수 있는 특정 도메인의 명시적인 선언이 필요합니다.

request mapping을 위해 PathPatternParser를 사용할 때 "path/**/other"와 같이 pattern 중간에 double wildcard가 있는 경우 이제 거부됩니다.
이 parser는 WebFlux application에서 default로 사용되며 Spring Framework 5.3부터 MVC application에 대해 opt-in으로 사용할 수 있습니다.
gh-24952를 참조하세요.

ForwardedHeaderFilter (Servlet)과 ForwardedHeaderTransformer (WebFlux)가 향상되었으며 이제 X-Forwarded-Prefix의 multiple value와 새로운 X-Forwarded-For / Forwarded: for= HTTP request header에 대해 지원합니다.

@ExceptionHandler method는 이제 match를 찾을 때 모든 exception cause를 체크합니다.
4.3 이전에는 first cause만 check 했었습니다.

UUID, Long및 그 외의 conversion-based type을 가진 Handler method argument가 null 변환 결과를 감지하여 missing value로 처리합니다. empty String이 null argument로 삽입되도록 하려면 required=false를 argument annotation으로 설정해야 합니다.
예를 들면 @RequestHeader(required=false) 또는 @Nullable로 argument를 선언합니다.

Spring MVC

LocaleResolver, ThemeResolver, FlashMapManagerRequestToViewNameTranslator bean이 이제 WebMvcConfigurationSupport level에서 @Bean annotation으로 선언되며 다른 Spring MVC default bean과의 일관성을 개선하고 DispatcherServlet에서 수행되는 reflection을 줄임으로써 GraalVM 호환성을 개선하였습니다.
Spring Boot 또는 XML application context based project는 영향을 받지 않아야 하지만 JavaConfig를 사용하는 비 Spring Boot Project는 이러한 default bean 중 하나를 @EnableWebMvc와 같은 configuration class와 함께 (잘 알려진 이름을 사용하여) 예를 들면 LocaleResolver와 같이 override 해야 할 수 있습니다.

@EnableWebMvc
@Configuration
public class WebConfig {

    @Bean
    public LocaleResolver localeResolver() {
        return new FixedLocaleResolver(new Locale("fr", "FR"));
    }
}

@RequestParam@RequestPart는 argument가 필요할 때(즉, 선택 사항으로 명시적으로 표시되지 않음) MultipartFile / Part 선언과 일관되게 Multipart와 Servlet Part collection/array에서 최소한 하나의 요소를 적용하여 argument를 null로 처리합니다.

Spring MVC가 더이상 .* suffix pattern matching을 default로 수행하지 않습니다.
마찬가지로 path extenstion(예: /person.pdf, /person.xml 등)도 requested content type을 해석하는 데 사용되지 않습니다.
reference documentation의 "Suffix Match" section을 참조하세요.

Spring WebFlux

List<T>와 함께 사용하는 @RequestPart는 이제 Spring MVC가 T[]를 처리하는 것과 일관되게 List<T>의 첫 번째 part를 변환합니다.
이전에는 각 part가 T로 변환되었습니다.
gh-22973을 참조하세요.

@EnableWebFlux가 이제 WebSocketHandlerAdapter bean 선언이 포함됩니다.
우선순위가 낮기 때문에 application에서 선언한 내용을 방해해서는 안되지만 이미 선언한 경우 제거할 수 있습니다.

WebClient는 이제 방출된 exception을 WebClientRequestException 또는 WebClientResponseException에 wrapping 합니다.
CodecException은 wrapping 되지 않고 계속 전파됩니다.
gh-23842를 참조하세요.

@Controller method에 주입된 UriComponentsBuilder argument가 이제 application에 상대적(즉, contextPath도 포함함)입니다.

org.synchronoss.cloud:nio-multipart-parser는 더 이상 WebFlux의 multipart 지원을 위해 필요한 의존성이 아닙니다.
대신 DefaultPartHttpMessageReader가 의존성 없이 추가되었습니다.
gh-21659를 참조하세요.

Testing

Spring TestContext Framework는 이제 enclosing class로부터 inheriting과 overriding 테스트에 관련된 annotation을 대체하기 위한 first-class 지원을 제공합니다.
이는 Spring의 test 지원과 함께 Junit Jupiter @Nested test class를 사용하기 위한 프로그래밍 모델을 향상합니다.
그라나 enclosing class의 annotation은 이제 default로 상속됩니다.
이것은 @Nested test class 중 일부가 Spring Framework 5.3으로 업그레이드한 후에 실패하게 될 수 있는 동작의 변경입니다.
Spring Framework 5.0 - 5.2.x에 있는 동작으로 되돌리려면 @Nested enclosing class의 최상위에 @NestedTestConfiguration(OVERRIDE) annotation을 사용하면 됩니다.
전체 project에 대해 OVERRIDE를 적용하려면 JVM system property나 classpath root의 spring.properties 파일(예: src/test/resources/spring.properties)의 entry로 spring.test.enclosing.configuration=override를 설정하면 됩니다.

자세한 내용은 Javadoc for @NestedTestConfigurationreference menual을 참조하세요.

MockMvc Kotllin DSL의 isOk, isOk() 같은 property syntax의 사용이 일부 깨지는 걸 경험할 수 있습니다.
향상된 Kotlin DSL로 인해 약간의 다른 변화가 있을 수 있습니다.
자세한 내용은 이 commit을 참조하세요.

반응형
profile

파란하늘의 지식창고

@Bluesky_

내용이 유익했다면 광고 배너를 클릭 해주세요