What Is New in Spring Boot 2.5
Spring Boot 2.5 introduces a significant set of updates, from core container enhancements to improved observability and cloud-native support. This version builds on the mature foundation while streamlining the developer experience for modern applications.
| Category | Key Changes |
|---|---|
| New Features | Docker Compose support, Config Tree binding, Graceful shutdown for Jetty & Tomcat, JUnit Jupiter 5.7 |
| Enhancements | Spring Boot Docker image publishing, Simplified DataSource initialization, Improved startup logging |
| Deprecations | Properties in `spring.config` hierarchy, `spring-boot-properties-migrator` |
| Dependency Upgrades | Spring Framework 5.3, Spring Data 2021.0, Spring Security 5.5, Kotlin 1.5, Groovy 3.0 |
How did Docker support improve?
Spring Boot 2.5 significantly enhances the Docker experience with two major features. First, it introduces
built-in support for Docker Compose, automatically starting services defined in compose.yaml during
application startup and shutting them down gracefully on exit.
Second, the spring-boot:build-image Maven goal now supports publishing the built image directly to a
Docker registry. This eliminates the manual step of running docker push after image creation,
streamlining CI/CD pipelines.
What are the key configuration changes?
A new mechanism for binding configuration from Kubernetes ConfigMaps and Secrets was added. You can now mount
configuration data as a volume, and Spring Boot will automatically bind properties from files in the directory
specified by spring.config.import=configtree:/path/to/config/.
This approach is more Kubernetes-native than using environment variables for complex configuration. It also simplifies permission management since the files can have restricted read access.
How does graceful shutdown work now?
Graceful shutdown support was extended beyond Undertow to include Tomcat and Jetty embedded web servers. When enabled, the web server stops accepting new requests and waits for a configurable timeout for ongoing requests to complete before shutting down.
In practice, this prevents abrupt connection termination during deployments or scaling events. You can configure
the timeout using server.shutdown=graceful and
spring.lifecycle.timeout-per-shutdown-phase in your application.properties.
What changed with DataSource initialization?
The initialization of embedded databases and DataSources was simplified with more intuitive defaults. Spring Boot now initializes the database using the default DataSource only, which resolves confusion when multiple DataSources are present.
For advanced cases, you can still customize initialization behavior using spring.sql.init.mode and
related properties. This change makes the common case simpler while preserving flexibility for complex
configurations.
Were there any startup performance improvements?
Yes, startup time and memory usage were optimized through several underlying changes. The most noticeable improvement comes from enhanced logging during startup - Spring Boot now prints fewer lines by default while still providing essential information.
Additionally, the way conditions are evaluated during auto-configuration was optimized, reducing overhead. For large applications with many dependencies, these optimizations can result in measurably faster startup times.
FAQ
How do I enable Docker Compose support in my Spring Boot 2.5 application?
Simply add a
compose.yaml file to your project root. Spring Boot will automatically detect it and start the
defined services when your application starts. You can disable this behavior with
spring.docker.compose.enabled=false.
What should I use instead of the deprecated spring.config properties?
Use the new
spring.config.import property instead. For example, instead of the old hierarchy-based approach,
you can now use spring.config.import=configtree:/path/to/config/ for Kubernetes-mounted config or
spring.config.import=classpath:application-secrets.properties for additional property files.
Does graceful shutdown work with all embedded web servers now?
Yes, Spring Boot 2.5 adds
graceful shutdown support for Tomcat and Jetty, complementing the existing support for Undertow. All three major
embedded servers now support waiting for ongoing requests to complete before shutting down.
How do I publish Docker images directly to a registry with Maven?
Use the
spring-boot:build-image goal with Docker registry credentials. You can configure the registry URL
and credentials in your Maven settings or pom.xml, and the image will be pushed automatically after being built.
What version of Java is required for Spring Boot 2.5?
Spring Boot 2.5 requires Java 8 as a
minimum but supports up to Java 16. However, for production use, we recommend Java 11 or later to take full
advantage of current JVM performance improvements and long-term support.