The latest update Spring Boot 2.3 is now available. Spring Boot 2.3 adds a few new noteworthy features, fixes some issues, updates dependencies, and includes improvements.
Spring Boot is an open source framework based on Java. Originally developed by Pivotal, it helps users create stand-alone, production-grade Spring-based applications with minimal configuration.
- Changes to minimum requirements
- Deprecations from Spring Boot 2.2
- New and Notable features of Spring Boot 2.3
- Java 14 support
- Build OCI images with Cloud Native Buildpacks
- Build layered jars for inclusion in a Docker image
- Predictable Classpath Ordering When Exploding Fat Jars
- Support of wildcard locations for configuration files
- Graceful shutdown
- Liveness and Readiness probes
- Spring Data Neumann
- R2DBC support
- Configurable base path for WebFlux applications
- Date-Time conversion in web applications
- Actuator Improvements
- RSocket support for Spring Integration
- Binding to Period
- Slice test for Web Services
- Dependency Upgrades
- Miscellaneous
- Deprecations in Spring Boot 2.3
Changes to minimum requirements
Spring Boot 2.3 requires:
- Gradle 6.3+ (if you are building with Gradle). 5.6.x is also supported but in a deprecated form.
- Jetty 9.4.22+ (if you are using Jetty as the embedded container)
Deprecations from Spring Boot 2.2
Most classes, methods and properties that were deprecated in Spring Boot 2.2 have been removed in this release. Please ensure that you aren’t calling deprecated methods before upgrading.
A number of properties have been renamed or deprecated. You can use the spring-boot-properties-migrator
module to identify those properties. Once added as a dependency to your project, this will not only analyze your application’s environment and print diagnostics on startup, but also temporarily migrate properties at runtime for you.
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-properties-migrator</artifactId> <scope>runtime</scope> </dependency>
runtime("org.springframework.boot:spring-boot-properties-migrator")
Note: Once you’re done with the migration, please make sure to remove this module from your project’s dependencies.
New and Notable features of Spring Boot 2.3
Java 14 support
Spring Boot 2.3 adds support for Java 14. Java 8 and 11 are also supported.
Build OCI images with Cloud Native Buildpacks
Support for building Docker images using Cloud Native Buildpacks and has been added to the Maven and Gradle plugins via the spring-boot:build-image
goal and the bootBuildImage
task. The Paketo Java buildpack is used by default to create images.
Build layered jars for inclusion in a Docker image
Support for building jar files with contents separated into layers has been added to the Maven and Gradle plugins. The layering separates the jar’s contents based on how frequently they will change. This separation allows more efficient Docker images to be built. Existing layers that have not changed can be reused with the layers that have changed being placed on top.
Depending on your application, you may want to tune how layers are created and add new ones. This can be done using configuration that describes how the jar can be separated into layers, and the order of those layers.
When you create a layered jar, the spring-boot-jarmode-layertools jar
will be added as a dependency to your jar by default (this can be disabled with build configuration). With this jar on the classpath, you can launch your application in a special mode which allows the bootstrap code to run something entirely different from your application, for example, something that extracts the layers. To see the options available, launch a fat jar with -Djarmode=layertools
as shown in the following example:
$ java -Djarmode=layertools -jar my-app.jar Usage: java -Djarmode=layertools -jar my-app.jar Available commands: list List layers from the jar that can be extracted extract Extracts layers from the jar for image creation help Help about any command
Predictable Classpath Ordering When Exploding Fat Jars
Fat jars built with Maven and Gradle now include an index file. When the jar is exploded, this index file is used to ensure that the ordering of the classpath is the same as when executing the jar directly.
Support of wildcard locations for configuration files
Spring Boot now supports wildcard locations when loading configuration files. By default, a wildcard location of config/*/
outside of your jar is supported. This is useful in an environment such as Kubernetes when there are multiple sources of config properties. For instance, if you have separate mysql and redis configurations, they can be picked automatically if you place them in /config
, i.e. /config/mysql/application.properties
and /config/redis/application.properties
.
Graceful shutdown
Graceful shutdown is supported with all four embedded web servers (Jetty, Reactor Netty, Tomcat, and Undertow) and with both reactive and Servlet-based web applications. When enabled using server.shutdown=graceful
, upon shutdown, the web server will no longer permit new requests and will wait for a grace period for active requests to complete. The grace period can be configured using spring.lifecycle.timeout-per-shutdown-phase
.
Liveness and Readiness probes
Spring Boot now has built-in knowledge of the availability of your application, tracking whether it is alive and whether it is ready to handle traffic. The health endpoint can be configured to expose the liveness (/actuator/health/liveness) and readiness (/actuator/health/readiness) of you application with the management.health.probes.enabled=true
configuration property. When running on Kubernetes this is done automatically.
Spring Data Neumann
Spring Boot 2.3 ships with a major Spring Data release. The Neumann release train is planned to ship major driver upgrades. This initial milestone covers all of major version increments and ships driver upgrades to Elasticsearch 7 and the DataStax Java driver 4.3 for Apache Cassandra. Team is working towards a second milestone in February and a third one in March. The next milestone Neumann M2 is planned to ship with driver upgrades for MongoDB and Couchbase. Finally, the GA release is planned for late April.
R2DBC support
When r2dbc is on the classpath, a ConnectionFactory is auto-configured with a similar arrangement than a jdbc DataSource. If Spring Data is on the classpath, repositories are auto-configured as well, as usual. R2DBC support also adds an health indicator for the connection factory, metrics for ConnectionPool and a test slice, @DataR2dbcTest.
Configurable base path for WebFlux applications
The base path of all web handlers a WebFlux application can now be configured. Use the spring.webflux.base-path
property to do so.
Date-Time conversion in web applications
The conversion of time and date-time values in web applications is now configurable via application properties. This complements that existing support for formatting date values. For MVC, the properties are spring.mvc.format.time
and spring.mvc.format.date-time
respectively. For WebFlux, the properties are spring.webflux.format.time
and spring.webflux.format.date-time
respectively.
In addition to taking a typical formatting pattern, the properties for configuring the formatting of dates, times, and date-times now support a value of iso. When set, the corresponding ISO-8601 formatting will be applied.
The iso values is supported by the following properties:
- spring.mvc.format.date
- spring.mvc.format.date-time
- spring.mvc.format.time
- spring.webflux.format.date
- spring.webflux.format.date-time
- spring.webflux.format.time
Actuator Improvements
- End-to-end Traceability for Configuration Properties
- Names in metrics endpoint are ordered alphabetically
- Query-less datasource health indicator
- Contributing additional tags to Web MVC and WebFlux metrics
- Contributing additional tags to Web MVC and WebFlux metrics
- Native Kafka metrics
RSocket support for Spring Integration
Spring Boot now provides auto-configuration for Spring Integration’s RSocket support. If spring-integration-rsocket
is available, developers can configure an RSocket server using "spring.rsocket.server.*"
properties and let it use IntegrationRSocketEndpoint or RSocketOutboundGateway components to handle incoming RSocket messages.
Binding to Period
If a property needs to express a period of time, you can do so using a java.time.Period
property. Similar to the Duration support, an easy format is supported (i.e. 10w for 10 weeks) as well as metadata support.
Slice test for Web Services
A new @WebServiceClientTest annotation has been added to support “slice” testing of Web Services.
Dependency Upgrades
Spring Boot 2.3 moves to new versions of several Spring projects:
- Spring Data Neumann
- Spring HATEOAS 1.1
- Spring Integration 5.3
- Spring Kafka 2.5
- Spring Security 5.3
- Spring Session Dragonfruit
Miscellaneous
Apart from the changes listed above, there have also been lots of minor tweaks and improvements including:
- The output from
spring-boot-autoconfigure-processor
is now repeatable, making it work better with Gradle’s build cache. - The Couchbase’s type key can be configured via
spring.data.couchbase.type-key
. - OAuth2 parameter binding is now available with
@WebMvcTest
. - Jetty’s backing queue can be configured using
server.jetty.max-queue-capacity
. - Liquibase’s tag support can be configured using
spring.liquibase.tag
. Clearing all checksums in the current changelog is now available via thespring.liquibase.clear-checksums
property. - Gradle metadata is now published.
DataSourceBuilder
can be used to configure aSimpleDriverDataSource
.DataSource
metrics have now a description.- Auto-detection of the cloud platform can be overridden using
spring.main.cloud-platform
. - Caching of responses from Actuator’s HTTP endpoints is now supported when the request has a principal.
- Maven support for creating a fat jar now honors the
project.build.outputTimestamp
property, allowing its output to be reproducible. - The Javadoc of the Maven plugin is now published.
- A customizer interface,
RSocketMessageHandlerCustomizer
, is provided for customizing the auto-configuredRSocketMessageHandler
, - A customizer interface,
DefaultCookieSerializerCustomizer
, is provided for customizing the auto-configuredDefaultCookieSerializer
. - Auto-configuration of the default servlet can now be disabled by setting
server.servlet.register-default-servlet
tofalse
. - A new condition,
@ConditionalOnWarDeployment
has been added. It can be used to detect when an application has been deployed as a war to a Servlet container or application server. - The properties migrator handles all deprecated properties, not only those with error levels.
- JDBC drivers are deregistered when destroying the war’s ServletContext.
- Redis’s sentinel password can be configured using
spring.redis.sentinel.password
.
Deprecations in Spring Boot 2.3
- The
spring.http.
properties have been moved toserver.servlet.encoding.
,spring.mvc.
andspring.codec.
SpringApplication#refresh(ApplicationContext)
has been deprecated in favour ofSpringApplication#refresh(ConfigurableApplicationContext)
.- The
ON_TRACE_PARAM
used with theserver.error.include-stacktrace
property has been renamed toON_PARAM
.