Spring Boot 2.5 Release Notes

지노·2021년 9월 6일
0

Spring Boot 2.4와 비교하여 개선된 점

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

SQL Script DataSource Initialization

  • schema.sqldata.sql script를 지원하는 메소드가 다시 설계되었습니다.
  • spring.datasource.properties가 새로운 spring.sql.init 대체되었습니다.
  • 이 properties는 R2DBC를 통해 액세스하는 SQL 데이터베이스를 초기화하는 데도 사용할 수 있습니다.

schema.sql and data.sql Files

  • Spring Boot 2.5.1 이상에서는 새로운 SQL initialization properties가 JDBC 및 R2DBC에 대한 embedded datasources 탐지를 지원합니다.
  • Default 설정으로, SQL 데이터베이스 초기화는 내장 메모리 데이터베이스를 사용하는 경우에만 수행됩니다.
  • 유형에 관계없이 SQL 데이터베이스를 초기화시키기 위해서는spring.sql.init.mode 속성에 대한 값을 always로 지정해야합니다.
  • 초기화를 활성화시키지 않기 위해서는 spring.sql.init.mode 속성에 대한 값을never로 지정해야합니다..

Separate Credentials

  • 새 스크립트 기반 SQL 데이터베이스 초기화에서는 스키마(DDL) 및 데이터(DML) 변경에 별도의 자격 증명을 사용할 수 없습니다.
  • 이로 인해 복잡성이 줄어들고 Flyway 및 Liquibase에 맞게 기능이 조정됩니다.
  • 스키마 및 데이터 초기화를 위해 별도의 자격 증명이 필요한 경우 직접 org.springframework.jdbc.datasource.init.DataSourceInitializer 빈을 정의해야합니다.

Hibernate and data.sql

  • data.sql 스크립트는 Hibernate가 초기화되기 전에 실행된다.
    이로 인해 Flyway, Liquibas의 스크립트 기반 기본 초기화 방안과 일치한다.

  • 만약 data.sql로 Hibernate로 생성한 스키마에 데이터를 추가하고 싶으면 spring.jpa.defer-datasource-initialization 값을 true 지정하면 된다.

  • 데이터베이스 초기화 기술을 혼합하는 것은 권장되지 않지만, data.sql을 통해 데이터가 추가되기 전에 schema.sql 스크립트를 사용하여 Hibernate로 생성된 스키마를 기반으로 작성할 수도 있습니다.

Initialization ordering

  • JdbcTemplate와 같이 잘 알려진 특정 유형의 Bean은 데이터베이스가 초기화된 후 초기화되도록 정렬됩니다.

  • DataSource와 직접적으로 사용하는 Bean이 있는 경우 클래스에 주석을 추가하거나 @Bean으로 등록된 메소드에 @DependsOnDatabase 주석을 추가하면 데이터베이스를 초기화한 후에 빈이 생성됨이 보장됩니다.

Flyway and Liquibase JDBC URLs

  • 현재 스프링에서 spring.flyway.url 또는 spring.liquibase.url로 정의하고 있엇다면 usernamepassword 속성을 추가적으로 제공해야 한다.

  • 스프링부트의 이전 버전에서는 이러한 설정은 spring.datasource 속성에서 파생되었지만 Datasource Bean을 제공하는 사람들에게는 문제가 있는 것으로 드러났다.

Spring Data Solr

  • Spring Data in 2021.0.0에서 Spring Data Solr가 제거되면서, auto-configuration for Spring Data Solr가 이번 배포에서 제거되었습니다.

Secure Info Endpoint

  • /info에 대한 actuator endpoint 더 이상 웹에서 기본으로 노출되지 않습니다.

  • 또한 Spring Security가 클래스 경로에 있고 응용 프로그램에 사용자 지정 보안 구성이 없는 경우 엔드포인트에는 기본적으로 인증된 액세스 권한이 필요합니다.

  • 이러한 새 기본값을 변경하려면 작동기 엔드포인트의 노출보안에 대한 설명서를 참조하십시오.

Task Scheduling Harmonization with Spring Integration

  • Spring Integration은 이제 자체 구성 대신 사용 가능한 TaskScheduler를 재사용한다.

  • 자동 구성에 의존하는 일반적인 응용 프로그램 설정에서 Spring Integration은 Pool 크기가 1인 자동 구성된 작업 스케줄러를 사용합니다.

  • Spring Integration의 기본값인 10개의 스레드를 복원하려면 'spring.task.scheduling.pool.size' 속성을 사용하십시오.

Default Expression Language (EL) Implementation

  • Spring Boot의 웹 및 유효성 검사 시작 프로그램에 포함된 EL 구현이 변경되었습니다.

  • Tomcat의 구현체(org.apache.tomcat.embed.tomcat-embed-el)가 Glassfish (org.glassfish:jakrta.el)참조 구현 대신 사용된다.

Messages in the Default Error View

  • 이제 기본 오류 보기의 'message' 특성이 표시되지 않으면 비워지지 않고 제거됩니다.

  • 오류 응답 JSON을 구문 분석할 경우 누락된 항목을 처리해야 할 수 있습니다.

  • 메시지를 포함하려는 경우에도 'server.error.include-message' 속성을 사용할 수 있습니다.

Logging Shutdown Hooks

We now register a logging shutdown hook by default for jar based applications to ensure that logging resources are released when the JVM exits.
If your application is deployed as a war then the shutdown hook is not registered since the servlet container usually handles logging concerns.

Most applications will want the shutdown hook. However, if your application has complex context hierarchies, then you may need to disable it.
You can use the logging.register-shutdown-hook property to do that.

Gradle Default jar and war Tasks

The Spring Boot Gradle Plugin no longer automatically disables the standard Gradle jar and war tasks.
Instead we now apply a classifier to those tasks.

If you prefer to disable those tasks, the reference documentation includes updated examples.

Cassandra Throttling Properties

Spring Boot no longer provides default values for spring.data.cassandra.request.throttler properties.
If you rely on max-queue-size, max-concurrent-requests, max-requests-per-second or drain-interval you should set values that make sense for your application.

Customizing jOOQ's DefaultConfiguration

To streamline the customization of jOOQ's DefaultConfiguration, a bean that implements DefaultConfigurationCustomizer can now be defined. This customiser callback should be used in favour of defining one or more *Provider beans, the support for which has now been deprecated.

Groovy 3

The default version of Groovy has been upgraded to 3.x. If you are using Groovy and also using Spock, you should also upgrade to the latest Groovy 3.0-compatible release of Spock 2.0. Alternatively, use the groovy.version to downgrade back to Groovy 2.5.

Minimum Requirements Changes

Projects built with Gradle now require Gradle 6.8 or later.

Hibernate Validator 6.2

The default version of Hibernate Validate has been upgraded to 6.2.x. Hibernate Validator 6.2 changes how the expression language is used to interpolate constraint messages.
Please seethis blog post from the Hibernate Validator team for further details.

Deprecations from Spring Boot 2.3 and 2.4

Reflecting the Spring Boot release compatibility policy, code deprecated in Spring Boot 2.3 has been removed in Spring Boot 2.5.
Code deprecated in Spring Boot 2.4 remains in place, and is scheduled for removal in Spring Boot 2.6.


New and Noteworthy

TIP: Check the configuration changelog for a complete overview of the changes in configuration.

Environment Variable Prefixes

It's now possible to specify a prefix for system environment variables so that you can run multiple different Spring Boot applications in the same environment.
Use SpringApplication.setEnvironmentPrefix(...) to set the prefix that you want to use when binding properties.

For example, the following will add a myapp prefix:

[source.java]

SpringApplication application = new SpringApplication(MyApp.class);
application.setEnvironmentPrefix("myapp");
application.run(args);

All properties will now expect a prefixed version.
For example, to change the server port you can set MYAPP_SERVER_PORT.

HTTP/2 over TCP (h2c)

All four embedded web containers now support HTTP/2 over TCP (h2c) without any manual customization. To enable h2c, set server.http2.enabled is true and leave server.ssl.enabled set to false (its default value).

As with the existing h2 support, depending on the embedded web server being used, the use of h2c may require additional dependencies. See the reference documentation for details.

Generic DataSource Initialization

A new generic mechanism is now available if you write code that initializes a DataSource.
This mechanism is also now used internally to setup correct bean dependencies for Flyway, Liquibase and Script based initialization.

Most developers won't need to directly make use of the new mechanism.
However, if you are developing a third-party starter for a data access library, you may want to provide a DependsOnDataSourceInitializationDetector.
See the updated reference documentation for details.

Database Initialization with R2DBC

Support for script-based initialization of an SQL database accessed via R2DBC has been added.
By default, scripts on the classpath named schema.sql and data.sql will be applied to the database automatically.
The initialization can be customized using the spring.sql.init.* configuration properties. Please
see the reference documentation for further details.

Liquibase DataSource

If you define a custom DataSource for use with Liquibase we now configure it using a SimpleDriverDataSource.
We previously used a pooling datasource which was unnecessary and inefficient for database initialization.

Layered WARs

The Spring Boot Maven and Gradle plugins now allow you to create layered WARs for use with Docker images.
Layered WARs work in a similar way to the Layered JAR support that was provided in earlier versions of Spring Boot.
Check out the Gradle and Maven reference documentation for more details.

Docker Image Building Support

Custom Buildpacks

The Maven and Gradle plugins both now support the use of custom Buildpacks.
You can set the buildpacks property to point at directories, tar.gz files, specific builder references or Docker images.

See the updated Gradle and Maven reference documentation for more details.

Bindings

The Maven and Gradle plugins now both support volume bindings that can be passed to the buildpack builder.
These allow you to bind local paths or volumes for the buildpack to use.

See the updated Gradle and Maven reference documentation for more details.

War Support

Both the Maven and Gradle plugin can now package executable war files into Docker images.
The existing mvn spring-boot:image or ./gradlew bootBuildImage commands should be used if you want to create a Docker image for your war.

OpenMetrics for Prometheus

The /actuator/prometheus actuator endpoint can now provide both standard Prometheus as well as OpenMetrics responses.
The response returned will depend on the accept header that is provided with the HTTP request.

Metrics for Spring Data Repositories

Actuator will now generate Micrometer metrics for Spring Data repositories.
By default, metrics are named spring.data.repository.invocations.
To learn more, please see the
relevant section of the reference documentation.

@Timed Metrics with WebFlux

Aligning its capabilities with those of Spring MVC, @Timed can now be used to manually enable timing of requests handled by WebFlux controllers and functional handlers.
To use manual timing, set management.metrics.web.server.request.autotime.enabled to false.

MongoDB Metrics

When using Actuator, metrics for Mongo's connection pool and commands sent by the client are now generated automatically.
To learn more about MongoDB metrics, please see the relevant section of the reference documentation.

Actuator Endpoint for Quartz

A /quartz endpoint has been added to Actuator.
It provides detailed information about Quartz jobs and triggers.
Please see {actuator-api-docs}#quartz[the relevant section of the Actuator's API documentation] for further details.

GET requests to actuator/startup

The actuator's startup endpoint now supports GET requests.
Unlike a POST request, a GET request to the endpoint does not drain the event buffer and events will continue to be held in memory.

Abstract Routing DataSource Health

Actuator's health endpoint now shows the health of the targets of an AbstractRoutingDataSource.
Each target DataSource is named using its routing key.
As before, to ignore routing data sources in the health endpoint, set management.health.db.ignore-routing-data-sources to true.

Java 16 Support

This release provides support and is tested against Java 16.
Spring Boot 2.5 remains compatible with Java 8.

Gradle 7 Support

The Spring Boot Gradle plugin supports and is tested against Gradle 7.0.x.

Jetty 10 Support

Spring Boot 2.5 can now use Jetty 10 as an embedded web server.
As Jetty 10 requires Java 11, our default Jetty version will remain as 9.

To upgrade to Jetty 10, use the jetty.version property to override the version.
You should also exclude org.eclipse.jetty.websocket:websocket-server and org.eclipse.jetty.websocket:javax-websocket-server-impl from spring-boot-starter-jetty as they are Jetty 9-specific.

Documentation Updates

-- 생략 --

기타 변경사항

Apart from the changes listed above, there have also been lots of minor tweaks and improvements including:

  • management.endpoints.web.cors.allowed-origin-patterns can now be used to configure the allowed origin patterns for Actuator endpoints
  • HttpSessionIdListener beans are now automatically registered with the servlet context
  • Couchbase now uses the auto-configured ObjectMapper by default
  • Elasticsearch's Sniffer is now auto-configured when its elasticsearch-rest-client-sniffer module is on the classpath
  • spring.data.cassandra.controlconnection.timeout can now be used to configure the timeout of Cassandra's control connection
  • spring.kafka.listener.only-log-record-metadata can now be used to configure what's logged when retries are being attempted
  • Support for Apache Phoenix, auto-detecting jdbc:phoenix JDBC URLs
  • Configuration properties for Rabbit's key store and trust store algorithms
  • The /actuator discovery page can now be disabled using the management.endpoints.web.discovery.enabled property.
  • The /actuator/configprops and actuator/env endpoints now have additional-keys-to-sanitize properties that can be used to sanitize keys.
  • You can now use a EndpointObjectNameFactory if you want to customize the name of JMX actuator endpoints.
  • A new DataSourceBuilder.derivedFrom(...) method has been added that allows you to build a new DataSource that's derived from an existing one.
  • When Spring Security is on the classpath, configuration properties can now be bound to RSAPublicKey and RSAPrivateKey.
  • The RabbitMQ ConnectionFactory used by Spring AMQP can now be customized using a ConnectionFactoryCustomizer bean.
  • Embedded database auto-configured can now be controlled using the new spring.datasource.embedded-database-connection configuration property. It can be set to any of the values of EmbeddedDatabaseConnection, including none to disable embedded database auto-configured entirely.
  • CloudPlatform can now automatically detect Azure App Service.
  • server.tomcat.keep-alive-timeout can be used to configure how long Tomcat will wait for another request before closing a keep-alive connection.
  • server.tomcat.max-keep-alive-requests can be used to control the maximum number of requests that can be made on a keep-alive connection before it is closed.
  • spring.webflux.session.cookie.same-site can be used to configure WebFlux's SameSite cookie policy. It is lax by default.
  • Apache HttpClient 5 is now auto-configured for use with WebClient.
  • A new ApplicationEnvironment class has been introduced which should improve a small performance boost.
  • You can now configure Netty memory using the spring.netty.leak-detection property.

Dependency Upgrades

몇몇 Spring Projects 종속성이 업데이트되었습니다.

  • Spring Data 2021.0
  • Spring Integration 5.5
  • Spring Security 5.5
  • Spring Session 2021.0
  • Spring HATEOAS 1.3
  • Spring Kafka 2.7.0

또한 몇몇 타사 종속성이 업데이트되었으며, 그 중 몇 가지는 다음과 같습니다.

  • Kotlin 1.5
  • Groovy 3.0
  • Flyway 7.7
  • Liquibase 4.3
  • Jackson 2.12
  • Kafka 2.7
  • Cassandra Driver 4.10
  • Embedded Mongo 3.0
  • Hibernate Validator 6.2
  • Jersey 2.33
  • Mockito 3.7
  • MongoDB 4.2
  • JUnit Jupiter 5.7
  • Elasticsearch 7.12

Notable Deprecations in Spring Boot 2.5

다음은 Spring Boot 2.5에서 deprecated된 주목할 만한 사항들입니다.

  • org.springframework.boot.actuate.endpoint.http 안에 ActuatorMediaTypeApiVersion 설정들은 org.springframework.boot.actuate.endpoint안에 것들과 동일하다.

  • jOOQ의 *Provider 콜백 인터페이스나 Settings 기능을 지원하는 Beans에 대한 지원은 deprecate 되었습니다, 대신 'DefaultConfigurationCustomizer'를 사용해야 합니다.

  • org.springframework.boot.autoconfigure.data.jpaEntityManagerFactoryDependsOnPostProcessororg.springframework.boot.orm.jpa로 이전되었다.

profile
Spring Framework를 이용한 웹 개발과 AWS 서비스, Container를 사용한 CI/CD 인프라에 관심이 있습니다.

0개의 댓글