파란하늘의 지식창고
article thumbnail
Published 2019. 10. 18. 06:03
Spring Boot 2.2 Release Notes Study/Java
반응형

Spring Boot 2.2 Release Notes

Upgrading from Spring Boot 2.1

Deprecations from Spring Boot 2.1

2.1에 deprecated 선언되었던 class, method, properties가 삭제되었다.

Spring Framework 5.2

Spring Framework가 5.2로 업그레이드 되었다.

JMX now disabled by default

JMX 기본 설정이 disabled 로 변경되었다.

해당 기능을 활성화 하려면 spring.jmx.enabled=true 설정을 사용한다.

IDE 특징을 사용하여 applicatio을 관리하는 경우 해당 flag도 활성화 할 수 있다.

Jakarta EE dependencies

javax. 를 사용하는 Java EE dependency를 jakarta. 를 사용하는 Jakarta EE dependency로 이동을 권장한다.

Java EE 는 향후에 제거될 예정이다.

Java EE 를 Jakarta EE로 마이그레이션하기 위한 일부로 두 개의 dependency가 최신 주요 릴리즈의 artifactId를 변경하였다.

  • com.sun.mail:javax.mail -> com.sun.mail:jakarta.mail
  • org.glassfish:javax.el -> org.glassfish:jakarta.el 

이 dependency를 사용하고 있는 경우 업데이트를 해야 한다.

JUnit5

spring-boot-starter-test는 이제 JUnit5를 기본으로 제공한다.

JUnit5의 vintage engine은 기본적으로 기존 JUnit4 기반의 test class를 지원하기 위해 포함되어 있으므로 준비가 되면 JUnit5로 마이그레이션 할 수 있다.

AssertJ 3.12

Iterator와 관련된 assertion에 대한 주요 API 변경 사항이 포함된 AssertJ 3.12로 업그레이드되었다.

자세한 내용은 AssertJ release notes를 참고한다.

Spring HATEOAS 1.0

몇 가지 주요 API 변경 사항이 포함된 Spring HATEOAS 1.0로 업그레이드 되었다.

자세한 내용은 Spring HATEOAS 1.0 M1 released를 참고한다.

DataSize migration for logging.file size-based properties

logging.file.max-size와 logging.file.total-size-cap은 이제 전용 FileSize 타입 대신 표준 DataSize 타입을 사용한다.

이 properties를 사용하는 경우 표준 형식에 맞게 변경해야 한다.

DataSource health

DataSource health indicator에 DataSource에 사용된 유효성 검증 조회가 있는 extra validationQuery 속성이 포함된다.

또한 hello 속성에서 제공했던 query 결과의 이름이 result로 변경되었다.

Elasticsearch

주요 API 변경사항이 포함된 Elasticsearch 6.7로 업그레이드 되었다.

자세한 내용은 6.5, 6.6, 6.7 문서를 참고한다.

Hibernate Dialect

Spring Boot는 이제 Hibernate가 탐지한 database를 기반으로 default dialect를 적용하는 대신 사용할 dialect를 선택할수 있게 되었다.

customization dialect를 설정한 경우 제거할 수 있다.

Actuator HTTP Trace and Auditing are disabled by default

default repository 구현이 in-memory이고 너무 많은 resource를 소비하고 cluster 친화적이지 않기 때문에 actuator의 HTTP Trace와 Auditing 기능이 default로 활성화되지 않게 되었다.

강력한 production 등급의 HTTP 추적을 위해서는 Spring Cloud Sleuth 같은 걸 사용할 것을 권장한다.

HTTP Tracing을 활성화하려면 HttpTraceRepository또는 AuditEventRepository를 구현하여 해당 기능을 다시 활성화 하는 bean을 제공하면 된다.

configuration properties는 이러한 bean이 있는 경우에도 해당 기능을 해제할 수 있다.

(management.auditevents.enabled 와 management.trace.http.enabled 설정 참조)

Gradle requirements

Gradle의 최소 요구 사항이 변경되었다.

Spring Boot는 이제 Gradle 4.10 이상이 필요하다.

Jetty logging configuration

server.jetty.accesslog.* configuration properties는 더 이상 사용할 수 없다.

application이 이러한 properties를 사용하는 경우 custom-format 과 format의 두 가지 새로운 key가 도입되었다.

format을 사용하면 기존 형식 중에서 선택할 수 있고 custom-format을 사용하면 고유한 형식을 사용할 수 있다.

server.jetty.accesslog.format=NCSA # enum with predefined formats: NCSA, EXTENDED_NCSA 
server.jetty.accesslog.custom-format= # String, custom format overriding the former if defined 

지원되지 않는 옵션은 이제 custom log format을 정의하고 jetty의 CustomRequestLog에 정의된 옵션을 사용하도록 변환된다.

Hamcrest 2.1

Hamcrest 2.1로 업그레이드 되었다.

org.hamcrest:hamcrest-core 또는 org.hamcrest:hamcrest-library에 직접 dependency를 가지고 있는 경우 새 결합 모듈인 org.hamcrest:hamcrest를 대신 사용해야 한다.

spring-boot-starter-test를 사용하는 경우 별도로 설정할 필요가 없다.

Freemarker templates configuration

Freemarker template의 기본 파일 확장자가 변경되었다.

기존 템플릿 파일의 이름을 *.ftl 에서 *.ftlh로 변경해야 한다.

Tomcat’s MBean Registry

Tomcat의 MBean registry는 기본 비활성화 되며 약 2Mb의 heap을 절약한다.

Tomcat의 MBean을 사용하려는 경우(예를 들어 Micrometer를 통해 metric을 expose 하는 경우) server.tomcat.mbeanregistry.enabled를 true로 설정하면 된다.

Logback max history

default logback 설정의  가 7일동안 를 사용하도록 업데이트 되었다.

logging.file.max-history configuration property로 설정할 수 있다.

HttpHiddenMethodFilter disabled by default

_method request parameter를 처리하는 필터는 자체에 parameter가 포함될 수 있는 경우 request body의 early consumption을 유발하기 때문에 default로 비활성화된다.

spring.webflux.hiddenmethod.filter.enabled나 spring.mvc.hiddenmethod.filter.enabled를 true로 설정하여 복원할 수 있다.

Health Indicator

새로운 health indicator group 기능을 구현하기 위한 많은 수의 class가 deprecated되었다.

만약 custom HealthIndicator를 CompositeHealthIndicatorConfiguration을 통해 설정하고 있다면 CompositeHealthContributorConfiguration 를 대신 사용해야 한다.

Health Endpoint JSON

/actuator/health endpoint의 json format result의 최상위 요소가 details에서 components로 이름이 변경되었다.

이는 HealthIndicator가 반환하는 실제 세부 정보를 composite health를 구성하는 component indicator와 구별하는데 도움이 된다.

actuator media type은 application/vnd.spring-boot.actuator.v2+json에서 application/vnd.spring-boot.actuator.v3+json으로 변경되었다.

만약 older format을 사용하는 tool이 있는 경우 Accept 헤더를 v2 media type으로 사용하면 된다.

DevTools config directory

global DevTools를 사용하기 위한 권장 위치는 ~/.config/spring-boot 이다.

다음 파일 중 하나를 사용할 수 있다.

  • spring-boot-devtools.properties
  • spring-boot-devtools.yaml
  • spring-boot-devtools.yml

자세한 내용은 reference documentation의 관련 섹션을 참조하면 된다.

Sample project renamed and relocated

sample project가 의도한 목적을 더 잘 반영하기 위해 smoke-test로 바뀌었다.

또한 source repository에서 재정리되어 이제 여기에서 찾을 수 있다.

New and Noteworthy

configuration changelog 에서 변경 사항에 대한 전체 개요를 확인할 수 있다.

Java 13 support

Spring Boot 2.2는 Java 13 지원이 추가되었다. 또한 Java 8과 Java 11도 지원한다.

Performance improvements

Spring Boot의 @Configuration에서 proxyBeanMethod=false를 선언하면 시작 시간과 memory 사용율을 줄일 수 있다.

proxyBeanMethods는 Spring Framework 5.2 M1에서 소개된 @Configuration에 새로 추가된 속성이다.

proxyBeanMethods는 @SpringBootApplication과 @SpringBootConfiguartion 에서도 사용가능한 속성이다.

gradle에서 bootRun 또는 maven에서 spring-boot:run으로 application 실행 시 JVM은 ( -Xverify:non 과 -XXTieredStopAtLevel=1) 일 사용하여 lanch 시간을 줄이기 위한 최적화를 하도록 flag를 구성한다.

이번 릴리즈에서는 몇가지 다른 성능 향상도 이루어졌다.

  • 많은 수의 configuration properties를 바인딩하는데 걸리는 시간이 크게 줄어듬
  • Spring Boot가 JPA Entity를 스캔하여 PersistenceUnit을 완전히 지원하가 되어 중복된 기능인 hibernate 자체 Entity scanning은 비활성화 됨.
  • bean을 생성해야 하는 경우에만 적용되도록 auto-configuration의 injection point가 개선됨
  • Actuator endpoint에 관계된 bean은 endpoint가 사용가능하고 expose 된 경우에만 생성됨 (JAX 또는 HTTP의 경우)
  • codec auto-configuration의 조건이 개선되어 codec을 더이상 사용하지 않으면 구성되지 않음
  • Tomcat의 MBean Registry는 default로 비활성화 되어 Tomcat의 메모리 영역을 약 2MB 줄임

Lazy initialization

spring.main.lazy-initialization property를 통해 시작 시간을 줄이기 위해 전역 lazy initialization을 활성화 할 수 있다.

이 기능을 사용하면 비용이 발생한다.

  • 지연된 초기화가 발생하는 동안 HTTP 요청 처리에 시간이 오래 걸릴 수 있음
  • 시작 시 일반적으로 발생하는 오류는 나중에 발생할 때까지 발생하지 않음

개별 bean은 @Lazy(false) 옵션을 사용하면 지연 초기화를 거부할 수 있다.

@Lazy(false) 를 사용하여 지연 초기화를 거부할 수 없는 경우 LazyInitializationExcludeFilter bean을 대신 사용할 수 있다.

예를 들어, IntegrationFlow bean을 지연 설정하지 않으려면 다음과 같이 사용할 수 있다.

@Bean
static LazyInitializationExcludeFilter integrationLazyInitExcludeFilter() {
    return LazyInitializationExcludeFilter.forBeanTypes(IntegrationFlow.class);
}

Spring Data Moore

Spring Boot 2.2는 Spring Data Moore를 사용한다.

자세한 내용은 What's new in Spring Data Moore blog post를 참조하면 된다.

Shutdown configuration of task execution and scheduling

auto-configure로 TaskExecutor 및 TaskScheduler의 종료 시 동작을 이제 구성할 수 있다.

자세한 내용은 spring.task.execution.shutdown과 spring.task.scheduling.shutdown namespace를 참조하면 된다.

Kubernetes detection

ConditionalOnCloudPlatform 으로 application이 kubernetes에서 실행되고 있는지 감지할 수 있다.

Test Application Arguments in integratoin tests

@ConfigurationProperties 주석이 달린 class는 이제 @EnableConfigurationProperties나 @Component를 사용하는 대신 class 경로 스캔을 통해 찾을 수 있다.

@SpringBootApplication을 사용하는 경우 @SpringBootApplication annotation이 있는 클래스가 포함된 패키지에 대해 기본적으로 스캔이 사용된다.

@ConfigurationPropertiesScan을 사용하여 스캔을 수동으로 활성화 하고 스캔된 package를 사용자 정의할 수 있다.

Immutable @ConfigurationProperties binding

Configuration properties는 이제 생성자 기반의 binding을 지원하여 @ConfigurationProperties annotation이 달린 class를 변경할 수 없다.

@ConfigurationProperties class 또는 해당 생성자 중 하나에 @ConstructorBinding annotation을 달면 생성자 기반 binding을 사용할 수 있다.

@DefaultValue 및 @DateTimeFormat 과 같은 annotation은 이제 configuration property binding 에서 제공하는 constructor parameter에 사용될 수 있다.

자세한 내용은 관련 섹션을 참조하면 된다.

RSocket Support

spring-boot-starter-rsocket 이 이번 릴리즈에 추가되었다.

이 starter는 RSocket을 사용하는 application을 빌드하는데 필요한 종속성을 제공한다.

RSocket strategy는 CBOR 및 JSON을 사용하여 RSocket payload encoding 및 decoding에 필요한 infrastructure를 제공하도록 자동 구성된다.

RSocketRequester.Builder는 RSocketRequest를 생성하여 원격 RSocket 서비스로 요청을 보낼 수 있도록 자동 구성 된다.

자세한 내용은 관련 섹션을 참조하면 된다.

spring-security-rsocket module이 class path 경로에 있을 때 Spring Security의 RSocket 통합을 위한 auto-configuration을 사용할 수 있다.

auto-configuration은 RSocket security를 활성화 하고 Spring Security의 Interceptor를 사용하여 RSocket factory를 구성한다.

RSocket server application을 테스트 할 때 local.rsocket.server.port property는 RSocket server가 listening 하는 포트로 설정된다.

@LocalRSocketServerPort를 사용하여 test class에 inject할 수 있다.

ApplicationContextRunner simple bean registration

ApplicationContextRunner test utility는 이제 bean inline에 등록할 수 있다.

자세한 내용은 withBean 을 참조하면 된다.

RestTemplateBuilder request customization

모든 request에 default header를 추가하고 general request customization을 가능하게 하는 method가 RequestTemplateBuild에 추가되었다.

Reactive Elasticsearch Auto-configuration

Spring Data Moore에 도입된 reactive Elasticsearch component에 대한 auto-configuration이 추가되었다.

ReactiveElasticSearchTemplate은 spring.data.elasticsearch.client.reactive.* property로 자동 구성된다.

reactive Elasticsearch repository에 대한 auto-configuration 지원도 제공된다.

Plain test support for Thread dump endpoint

threaddump actuator endpoint 는 이제 Thread Dump Anaylzerhttps://fastthread.io와 와 호환되는 plain text로 thread dump를 반환할 수 있다.

Configurable converters for Actuator endpoint input parameters

Actuator @Endpoint input parameter는 사용자 정의 @EndpointConverter 로 설정한 convertor를 사용하여 관리할 수 있다.

Callback for Redis cache configuration

RedisCacheManager configuration이 개선되었고 RedisCacheManagerBuilderCustomizer bean을 사용하면 변경 불가능한 RedisCacheManager를 configuration 하기 전에 Builder에 대한 handle을 얻을 수 있다.

Qualifier for Spring Batch datasource

여러 datasource가 있는 환경에서 DataSource bean은 @BatchDataSource를 선언하여 Spring Batch에서 사용되는 것을 표시할 수 있다.

Build info repeatable output

build info goal은 build.time 처리 방법을 구성할 수 있는 추가 시간 property가 있다.

build.properties의 출력을 반복 가능하게 하기 위해 완전히 비활성화 하거나 고정 시간으로 설정할 수 있다.

Health indicator for Hazelcast

Hazelcast에 HealthIndicator가 제공된다.

Idle JDBC connections metrics

이제 size와 idle metric을 추적하여 connection pool의 전체 size를 추적할 수 있다.

custom DataSourcePoolMetaData 구현이 있는 경우 getIdle method 구현도 고려한다.

Healthindicator groups

health indicator를 그룹으로 구성할 수 있다.

예를 들어 application을 kubernetes에 배포할 때 "liveness" 와 "readiness" probe에 대해 다른 health indicator set를 원할 수 있다.

configuration properties를 통해 group을 구성할 수 있다.

다음의 경우 datasource indicator만 있는 custom group을 만든다.

management.endpoint.health.group.custom.include=db

localhost:8080/actuator/health/custom 을 통해 사용자 정의 그룹을 호출할 수 있다.

자세한 내용은 reference documentation을 참조하면 된다.

Health Endpoint component details

/actuator/health 에서 반환된 component detail을 detail과 독립적으로 표시하도록 구성할 수 있다.

management.endpoint.health.show-components property는 detail을 표시하는 것과 유사한 방식으로 작동하며 권한 부여 시 또는 항상 승인되지 않도록 설정할 수 있다.

예를 들어 시스템 상태를 표시하기 위해 구성된 개별 health indicator를 항상 표시하고 싶지만 세부 정보르르 표시하지 않으려는 경우 다음과 같이 사용할 수 있다.

management.endpoint.health.show-components=always
management.endpoint.health.show-details=never

health indicator group에서도 동일한 속성을 설정할 수 있다.

Auto-configuration for Flyway JavaMigrations

Flyway는 application context에 있는 JavaMagration bean을 사용하도록 자동 구성된다.

Sanitization of URI Properties in Actuator Endpoints

configprops 및 end end point 가 수행하는 sanitization이 URI 특성을 포함하도록 개선되었다.

URI의 사용자 정보에서 찾은 모든 비밀번호가 삭제된다.

Banners

ASCII banner file은 {AnciColor.NNN} 을 사용하여 ANSI 256 color escape code를 사용할 수 있다. (NNN은 색상 코드)

spring.banner.image.bitdepth property를 8로 설정하여 image banner와 함께 사용할 수 있다.

ASCII block 문자를 사용하여 차단하도록 설정할 수 있는 spring.banner.image.pixelmode property도 추가되었다.

아래와 같이 사용된다.

animated-ascii-art-256

SAML Auto-configuration

spring-security-saml2-server-provider module이 classpath에 있을 때 Spring Security의 SAML 2.0 Relying Party에 대한 auto-configuration을 사용할 수 있다.

spring.security.saml2.relyingparty.registration.* property를 사용하여 Relying party를 등록할 수 있다.

Dependency Upgrades

Spring Boot 2.2는 몇몇 Spring project를 새 버전으로 이동한다.

  • Reactor Dysprosium
  • Spring AMQP 2.2
  • Spring Batch 4.2
  • Spring Data Moore
  • Spring Framework 5.2
  • Spring HATEOAS 1.0
  • Spring Integration 5.2
  • Spring Kafka 2.3
  • Spring Security 5.2
  • Spring Session Corn

수많은 third-party dependency도 업데이트 되었으며 그 중 일부는 다음과 같다.

  • Artemis 2.9
  • Elasticsearch 6.7
  • Flyway 6.0
  • Git Commit ID Plugin 3.0
  • Hazelcast 3.12
  • HSQLDB 2.5
  • Jackson 2.10
  • Jedis 3.1
  • Jersey 2.29
  • Kafka 2.3
  • Lettuce 5.2
  • Micrometer 1.3
  • Mockito 3.1
  • Solr 8.0

Miscellaneous

위에 나열된 변경 사항 외에도 다음과 같은 minor tweak 및 개선 사항이 포함되었다.

  • Servlet을 actuator endpoint로 wrapping하는 경우 loadOnStartup 구성 가능
  • Flyway bootstrap failure는 전용 FailureAnalyzer로 처리됨
  • Kafka batch listener에 대한 MessageConvertor가 올바로 자동 구성됨
  • Jaybird 4에 대한 지원이 추가됨 (jdbc:firebird 접두사)
  • Neo4j-OGM 기본 유형에 대한 opt-in 지원이 추가됨
  • client-side HTTP-metric에 outcome tag가 있음
  • third-party dependency가 다수 업그레이드됨
  • https를 사용하여 Prometheus push gateway를 구성할 수 있음
  • Printer 및 Parser bean은 application conversion service에 자동으로 등록됨.
  • H2 console auto-configuration을 사용하면 시작 시 JDBC 연결 URL이 기록되어 쉽게 연결할 수 있음
  • Couchbase role-based access는 이제 spring.couchbase.username 및 spring.couchbase.password를 통해 지원됨
  • OAuth2 resource server opaque token authentication에 대한 지원이 추가되었으며 spring.security.oauth2.resourceserver.opaquetoken configuration property를 사용하여 구성할 수 있음
  • spring.config.location이 PropertySourceLoader가 읽을 수 없는 확장자를 가진 파일을 지정하면 application이 빠르게 fail됨
  • application을 repackage하는데 사용할 layout은 spring-boot.repackage.layout property를 사용하여 maven과 함께 command line에서 설정할 수 있음
  • RestTemplateBuilder#defaultHeader 는 둘 이상의 값을 허용함
  • custom resource handler가 favicon을 제공할 수 있음
  • Kafka의 RecordInterceptor가 감지되어 자동 구성된 listener container와 연관됨
  • YAML configuration은 이제 boolea type에 대해 on 또는 off를 사용할 수 있음
  • 별도의 management port를 사용할 때 actuator discovery page를 사용할 수 있음
  • @WebMvcTest는 이제 HandlerInterceptor bean을 scan 함
  • @WebFluxTest는 WebFilter bean을 scan 함
  • JMS listener container의 receive를 위한 timeout 설정 가능
  • Spring session의 flush mode를 지원함
  • Spring AMQP의 confirm-type을 지원함
  • Jetty의 thread pool을 설정하기 위한 application property
  • @AutoConfigureMockMvc 를 Junit5와 같이 사용하여 병렬 test 실행을 지원
  • "Fat Jar"에서 Zip64 파일을 지원함
  • logback configuration에 ROLLING_FILE_LOG_PATTERN을 사용할 수 있도록 노출함
  • @SpringBootText에서 customized WebTestClient를 inject하여 사용할 수 있음
  • Oracle의 JDBC driver에 대한 dependency management가 추가됨
  • Awaitility에 대한 dependency management가 추가됨

Deprecations in Spring Boot 2.2

  • logging.file property는 logging.file.name 으로 변경됨
  • logging.path property는 logging.file.path 로 변경됨
  • server.connection-timeout property는 동작이 완전히 동일하지 않으므로 server-specific 특성을 위해 더이상 사용되지 않음
  • server.forward-headers-strategy를 위해 server.use-forward-headers 속성은 더이상 사용되지 않음
    이전에 server.use-forward-headers=true 는 웹 서버 기본 지원을 사용하였음
    이제 server.forward-headers-strategy=native 로 동일한 결과를 얻을 수 있음
    각 서버에는 특정 동작이 있으므로 Spring의 ForwardedHeaderFilter를 사용하는 대안을 제공함 : server.forward-headers-strategy=framework
    개발자는 사용 사례에 가장 적합한 옵션을 사용해야함
  • ReactiveWebServerApplicationContext#getWebServerFactory
  • Maven plugin의 agent property는 agents로 이름이 변경됨
  • Joda time 지원이 java.time을 위해 더이상 사용되지 않음
  • ApplicationHealthIndicator in favour of PingHealthIndicator that is always contributed
  • ConfigurationBeanFactoryMetadata in favour of ConfigurationPropertiesBean.
  • ConfigurationPropertiesBindingPostProcessor constructors in favor of @EnableConfigurationProperties or the register method.
  • ConfigurationPropertiesBindingPostProcessor.VALIDATOR_BEAN_NAME는 EnableConfigurationProperties.VALIDATOR_BEAN_NAME 로 이동함
  • ConfigurationPropertiesBindingPostProcessorRegistrar in favor of @EnableConfigurationProperties.
  • WebTestClientBuilderCustomizer 가 org.springframework.boot.test.web.reactive.server 로 재배치됨

 

반응형
profile

파란하늘의 지식창고

@Bluesky_

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