파란하늘의 지식창고
Published 2023. 5. 26. 22:17
Spring Boot 3.1 Release Notes Study/Java
반응형

전체 Release Notes 목록은 이곳에서 확인할 수 있습니다.

https://luvstudy.tistory.com/tag/Release%20Notes


https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.1-Release-Notes

19 revision 기준으로 작성됨

Upgrading from Spring Boot 3.0

Dependency Management for Apache HttpClient 4

Spring Framework 6에서는 Apache HttpClient 5를 선호하기 위해 RestTemplate 을 사용하는 Apache HttpClient 4에 대한 지원이 제거되었습니다.
Spring Boot 3.0에는 HttpClient 4와 5 모두에 대한 종속성 관리가 포함되어 있습니다.
HttpClient 4를 계속 사용하는 애플리케이션은 RestTemplate 을 사용할 때 진단하기 어려운 error가 발생할 수 있습니다.

Spring Boot 3.1에서는 HttpClient 4에 대한 종속성 관리가 제거되어 사용자가 대신 HttpClient 5로 이동하도록 권장합니다.

Servlet and Filter Registrations

이제 등록에 실패하면 경고를 로깅하는 대신 ServletRegistrationBeanFilterRegistrationBean class가 IllegalStateException 을 발생시켜 실패합니다.
이전 동작이 필요한 경우 등록 bean에서 setIgnoreRegistrationFailure(true) 를 호출해야 합니다.

Git Commit ID Maven Plugin Version Property

io.github.git-commit-id:git-commit-id-maven-plugin 의 version을 재정의하는 데 사용되는 property가 해당 artiface name과 일치하도록 업데이트 되었습니다.
이 변경 사항을 적용하려면 pom.xml 에서 git-commit-id-plugin.versiongit-commit-id-maven-plugin.version 으로 바꾸세요.

Spring Kafka Retry Topic Auto-configuration

auto-configure된 retryable topic configuration(spring.kafka.retry.topic.enabled: true )과 함께 Apache Kafka를 사용하는 경우, maxDelay 를 가진 expotential back off와 함께 maxDelay level의 모든 retry가 이제 동일한 topic으로 전송됩니다.
이전에는 max delay를 초과한 경우에도 각 retry에 대해 별도의 topic이 사용되었습니다.

예를 들어 max retry 시도 횟수 5 , delay 1s , multiplier 2, max delay 3s 로 설정하면 초기 실패 후 1초, 2초, 3초, 3초 간격으로 retry가 수행됩니다.
이전 버전의 Spring Boot에서는 프레임워크가 someTopic , someTopic-retry-0 , someTopic-retry-1 , someTopic-retry-2 , someTopic-retry-3someTopic-retry-dlt 의 6개의 topic을 생성합니다.
이 변경 사항으로 인해 일부 someTopic-retry-3 topic이 만들어지지 않고 대신 3초 재시도 모두 someTopic-retry-2 에 포함됩니다.
이전 Spring Boot 버전에서 마이그레이션한 후에는 모든 record가 소비된 후에 someTopic-retry-3 topic을 안전하게 삭제할 수 있습니다.

Dependency Management for Testcontainers

이제 Spring Boot의 종속성 관리에는 Testcontainer가 포함됩니다.
필요한 경우, Spring Boot에서 관리되는 버전은 testcontainers.version property를 사용하여 재정의할 수 있습니다.

Hibernate 6.2

Spring Boot 3.1에서Hibernate 6.2로 업그레이드됩니다.
이 업그레이드가 애플리케이션에 어떤 영향을 미칠 수 있는지 알아보려면 Hibernate 6.2 migration guide를 참조하세요.

Jackson 2.15

Spring Boot 3.1에서 Jackson 2.15로 업그레이드됩니다.
이것이 애플리케이션에 어떤 영향을 미칠 수 있는지 알아보려면 Jackson wiki를 참조하세요.

2.15에서 주목할 만한 변경 사항 중 하나는 processing limit이 도입된 것입니다.
이러한 제약 조건을 조정하려면 다음과 유사하게 Jackson2ObjectMapperBuilderCustomizer 를 정의하세요:

@Bean
Jackson2ObjectMapperBuilderCustomizer customStreamReadConstraints() {
    return (builder) -> builder.postConfigurer((objectMapper) -> objectMapper.getFactory()
        .setStreamReadConstraints(StreamReadConstraints.builder().maxNestingDepth(2000).build()));
}

Mockito 5

Spring Boot 3.1은 Mockito 5, 특히 5.3으로 업그레이드됩니다.
Mockito 5.x 라인의 주목할 만한 변경 사항에 대해 알아보려면 Mockito release note를 참조하세요.

Health Group Membership Validation

이제 구성된 health group의 membership이 시작 시 유효성 검사를 합니다.
존재하지 않는 health indicator가 포함되거나 제외된 경우 startup이 실패합니다.
이 유효성 검사를 비활성화하여 이전 버전의 동작으로 복원하려면 management.endpoint.health.validate-group-membershipfalse 로 설정하면 됩니다.

Minimum Requirements Changes

None.

New and Noteworthy

Tip

Configuration의 변경 사항에 대한 전체 개요는 configuration changelog를 확인하세요.

Service Connections

새로운 service connection 개념이 도입되었습니다.
이러한 connection은 애플리케이션에서 ConnectionDetails bean으로 표시됩니다.
이러한 bean은 remove service에 대한 connection을 설정하는 데 필요한 세부 정보를 제공하며, Spring Boot의 auto configuration이 ConnectionDetails bean을 사용하도록 업데이트되었습니다.
이러한 bean을 사용할 수 있게 되면 connection configuration property보다 우선합니다.
connection pool의 size 및 동작을 제어하는 property 등 connection 자체와 관련이 없는 configuration property는 계속 사용됩니다.

이 하위 수준 기능은 ConnectionDetails bean을 정의하여 service connection을 auto configure하는 다른 상위 수준 기능을 위한 building block으로 사용됩니다.

Property-based ConnectionDetails Beans

적절한 ...ConnectionDetails bean이 다른 곳에 정의되어 있지 않은 경우, Spring Boot의 auto-configuration은 관련 configuration property를 기반으로 자체적으로 정의하도록 업데이트되었습니다.
따라서 해당 bean을 사용할 수 없고 property 기반 구성에 대한 fallback이 필요한 경우를 처리할 필요 없이 ...ConnectionDetails 를 주입할 수 있습니다.

Testcontainers

Using Testcontainers at Development Time

개발 시점에 Testcontainer를 사용하여 external service를 관리할 수 있는 기능이 도입되었습니다.

개발 시 Testcontainer를 사용할 때 test main method를 통해 application을 실행하는 데 새로운 Maven goal(spring-boot:test-run )과 Gradle task(bootTestRun )를 사용할 수 있습니다.

Testconainer Container instance를 static field로 선언하는 class는 새로운 @ImportTestcontainers annotation을 사용하여 import 할 수 있습니다.
자세한 내용은 reference documentation을 참조하세요.

Testcontainer lifecycle 관리가 개선되어 container가 먼저 초기화되고 마지막으로 파기되도록 합니다.
resulable container에 대한 지원도 개선되었습니다.

이제 Container @Bean method에서 property를 기여하기 위해 DynamicPropertyRegistry 를 주입할 수 있습니다.
이 method는 테스트에서 사용할 수 있는 @DynamicPropertySource 와 유사한 방식으로 작동합니다.
자세한 내용은 reference documentation을 참조하세요.

Testcontainers Service Connections

Testcontainer를 사용할 때 일반적으로 container의 설정을 기반으로 application property를 구성하기 위해 @DynamicPropertySource 가 사용됩니다:

@Container
static GenericContainer redis = new GenericContainer(DockerImageName.parse("redis").withTag("4.0.14"));

// …

@DynamicPropertySource
static void redisProperties(DynamicPropertyRegistry registry) {
    registry.add("spring.data.redis.host", redis::getHost);
    registry.add("spring.data.redis.port", redis::getFirstMappedPort);
}

이제 다음과 같이 단순화 할 수 있습니다.

@Container
@ServiceConnection
static GenericContainer redis = new GenericContainer(DockerImageName.parse("redis").withTag("4.0.14"));

여기서 @ServiceConnection 은 container가 Redis connection 세부 정보의 소스로 사용되어야 함을 나타냅니다.
@ServiceConnection annotation을 제공하는 spring-boot-testcontainers module은 container에서 이러한 세부 정보를 추출하는 동시에 Testcontainers API를 사용하여 container를 정의하고 구성할 수 있도록 합니다.

현재 @ServiceConnection annotation에서 지원되는 서비스의 전체 목록은 reference documentation을 참조하세요.

Docker Compose

새로운 module인 spring-boot-docker-compose 는 Docker Compose와의 통합을 제공합니다.
앱이 시작될 때 Docker Compose 통합은 현재 작업 디렉토리에서 구성 파일을 찾습니다.
지원되는 파일은 다음과 같습니다:

  • compose.yaml
  • compose.yml
  • docker-compose.yaml
  • docker-compose.yml

비표준 파일을 사용하려면 spring.docker.compose.file property를 설정하세요.

기본적으로 configuration file에 선언된 service는 docker compose up 을 사용하여 시작되고 해당 service에 대한 connection details bean이 application context에 추가되므로 추가 configuration 없이 service를 사용할 수 있습니다.
application이 중지되면 docker compose down 을 사용하여 서비스가 종료됩니다.
이 lifecycle 관리와 서비스를 시작하고 종료하는 데 사용되는 명령은 spring.docker.compose.lifecycle-management , spring.docker.compose.startup.commandspring.docker.compose.shutdown.command configuration property를 사용하여 사용자 지정할 수 있습니다.

현재 지원되는 서비스 목록을 포함한 자세한 내용은 reference documentation을 참조하세요.

SSL Configuration

이제 Java KeyStore 및 PEM-encoded 인증서와 같은 SSL trust material을 property를 사용하여 구성하고 embedded web server, data service, RestTemplateWebClient 와 같은 다양한 유형의 connection에 보다 일관된 방식으로 적용할 수 있습니다.

자세한 내용은 reference documentation을 참조하세요.

Auto-configuration for Spring Authorization Server

이번 release에서는 새로운 spring-boot-starter-oauth2-authorization-server starter와 함께 Spring Authorization Server project에 대한 지원이 제공됩니다.
자세한 내용은 Spring Boot reference documentation의 Authorization Server section에서 확인할 수 있습니다.

Docker Image Building

Image Created Date and Time

이제 spring-boot:build-image Maven goal 및 bootBuildImage Gradle task로 생성된 이미지의 metadata에서 Created field value를 사용자가 지정한 날짜로 설정하거나 현재 날짜와 시간을 사용하도록 now 로 설정하는 데 사용할 수 있는 createdDate configuration option이 있습니다.
자세한 내용은 GradleMaven plugin documentation을 참조하세요.

Image Application Directory

이제 spring-boot:build-image Maven goal 및 bootBuildImage gradle task에 buildpack이 사용할 application content를 업로드 할 builder image의 위치를 설정하는 데 사용할 수 있는 applicationDirectory configuration option이 있습니다.
이 위치는 생성된 image에서 application content의 위치이기도 합니다.
자세한 내용은 GradleMaven plugin documentation을 참조하세요.

Spring for GraphQL

Exception Handling

controller 또는 @ControllerAdvice 에 선언된 @GraphQlExceptionHandler method는 이제 controller method invocation을 위해 Spring for GraphQL에서 기본적으로 지원됩니다.
또한 Spring Boot는 GraphQlSource configuration을 통해 QueryDslDataFetcher , QueryByExampleDataFetcher 등과 같은 기타(컨트롤러가 아닌) DataFetcher 구현에 대한 @ControllerAdvice exception handling을 auto configuraion합니다.

Pagination and Sorting

Spring Data가 classpath에 있는 경우, 이제 GraphQL용 Spring이 pagenation 및 sorting을 지원하도록 auto configuration됩니다.

Improved Schema Type Generation

GraphQlSource 는 이제 ConnectionTypeDefinitionConfigurer 로 auto configuraion 됩니다.
이 구성자는 type definition name이 "Connection"으로 끝나는 field를 찾아 GraphQL Cursor Connections Specification으로 간주하여 Connection Type 을 생성하고, 필요한 type definition이 아직 없는 경우 추가합니다.

Support for Exporting Traces Using OTLP

classpath에 io.opentelemetry:opentelemetry-exporter-otlp 가 있으면 OtlpHttpSpanExporter 가 auto configuration 됩니다.
exoirter의 configuration은 management.otlp.tracing.* configuration property를 사용하여 사용자 지정할 수 있습니다.

Wavefront Span Tag Customization

Wavefront를 사용 중이고 RED metric에 대한 span tag를 사용자 지정하려는 경우, 이제 이 작업을 수행할 수 있는 management.wavefront.trace-derived-custom-tag-keys 라는 새로운 propertt가 있습니다.
자세한 내용은 #34194를 참조하세요.

Different log levels for file and console

Logback 또는 Log4j2를 사용하는 경우 이제 console log와 file log에 대해 서로 다른 log level을 설정할 수 있는 옵션이 있습니다.
이 옵션은 configuration property logging.threshold.consolelogging.threshold.file 을 사용하여 설정할 수 있습니다.

Maximum HTTP Response Header Size

이제 Tomcat 또는 Jetty를 사용하는 경우 최대 HTTP response header size를 제한할 수 있습니다.
Tomcat의 경우 server.tomcat.max-http-response-header-size property를 사용할 수 있고, Jetty의 경우 server.jetty.max-http-response-header-size property를 사용할 수 있습니다.
기본적으로 response header는 8kb 로 제한됩니다.

ActiveMQ Support

Spring Boot 3.0에서 제거되었던 ActiveMQ auto-configuration에 대한 지원이 복원되었습니다.

Dependency Upgrades

Spring Boot 3.1.0은 여러 Spring 프로젝트의 새 버전으로 이동합니다:

수많은 타사 종속성도 업데이트되었는데, 그 중 주목할 만한 몇 가지를 소개하면 다음과 같습니다:

Miscellaneous

위에 나열된 변경 사항 외에도 다음과 같은 많은 사소한 조정과 개선이 이루어졌습니다:

  • 이제 auto-configuration 된 KafkaListenerContainerFactorySpring Kafka ContainerCustomizer bean이 적용됩니다.
  • management.otlp.metrics.export.headers property가 추가되어 OTLP registry로 header 전송을 지원합니다.
  • 이제 AOT processing에서 JoranConfigurators bean을 사용할 수 있습니다.
  • spring.kafka.adminclose-timeout , operation-timeout , auto-startupauto-create property가 추가되었습니다.
  • 이제 auto-configuration된 ConcurrentKafkaListenerContainerFactoryBatchInterceptor bean이 적용됩니다.
  • Nomad가 인정된 CloudPlaform value 목록에 추가되었습니다.
  • 이제 spring.jmx 에 대한 registration-policy property를 지정할 수 있습니다.
  • SanitizableDatawithSanitizedValue utility method가 추가되었습니다.
  • RabbitTemplateCustomizer 가 도입되었습니다. 이 유형의 bean은 auto-configuration된 RabbitTemplate 를 사용자 정의합니다.
  • 이제 CNB Platform API 0.11이 지원됩니다.
  • spring-boot-starter-parentmaven.compiler.release 를 구성된 Java version으로 설정합니다.
  • 이제 -Dspring-boot.build-info.skip 을 설정하여 build-info goal을 건너뛸 수 있습니다.
  • Micrometer의 OtlpMeterRegistry 에 대한 Aggregation temporality configuration을 지원합니다.
  • Log4j2 및 Logback에서 추가 색상을 지원합니다.
  • R2DBC MySQL driver(io.asyncer:r2dbc-mysql )에 대한 종속성 관리가 추가되었습니다.
  • R2DBC MariaDB driver(org.mariadb:r2dbc-mariadb )에 대한 종속성 관리가 추가되었습니다.
  • OpenTelemetry를 사용하는 경우, auto-configuration된 SdkTracerProvider 를 생성하는 데 사용되는 SdkTracerProviderBuilderSdkTracerProviderBuilderCustomizer bean을 정의하여 커스터마이징할 수 있습니다.
  • MockServerRestTemplateCustomizer 는 이제 새로운 setBufferContent method를 통해 content buffering 활성화를 지원합니다.
  • 이제 Spring Batch가 auto-configuration 될 때 사용하는 conversion service를 BatchConversionServiceCustomizer bean을 정의하여 사용자 지정할 수 있습니다.
  • JWK Set URI에 대한 JTW decoder를 생성하는 데 사용되는 builder는 JwkSetUriReactiveJwtDecoderBuilderCustomizer 또는 JwkSetUriJwtDecoderBuilderCustomizer bean을 정의하여 커스터마이즈할 수 있습니다.
  • io.r2dbc:r2dbc-mssql 에 대한 종속성 관리가 복원되었습니다.
  • 이제 Logback의 root log level이 가능한 한 빨리 INFO 로 기본 설정됩니다.
  • 기본적으로 Docker Compose는 이제 down 이 아닌 stop 을 사용하여 중지됩니다.

Deprecations in Spring Boot 3.1.0

  • spring.kafka.streams.cache-max-size-bufferingspring.kafka.streams.state-store-cache-max-size 를 위해 더 이상 사용되지 않습니다.
  • StandardMongoClientSettingsBuilderCustomizerMongoPropertiesClientSettingsBuilderCustomizer 로 변경합니다.
  • MongoPropertiesClientSettingsBuilderCustomizerStandardMongoClientSettingsBuilderCustomizer 로 변경합니다.
  • org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesRegistrationAdapterorg.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesMapper 로 변경합니다.
  • org.springframework.boot.web.server.SslStoreProvider 는 SSL bundle을 위해 더 이상 사용되지 않습니다.
반응형
profile

파란하늘의 지식창고

@Bluesky_

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