What Is New in Spring Boot 2.4
Spring Boot 2.4 delivers significant updates to configuration handling, cloud integration, and developer tooling. This release streamlines the path to production with better Docker image support and refined property management.
| Category | Key Changes |
|---|---|
| New Features | Config Data API, Docker image building, Volume mounts |
| Improvements | Spring Cloud Bootstrap context, Graceful shutdown, Health groups |
| Deprecations | Legacy configuration processing, spring.config.location |
| Dependency Updates | Spring Framework 5.3, Spring Data 2020.0, Spring Security 5.4 |
How did configuration handling change in 2.4?
The biggest shift is the new Config Data API, which completely overhauls how external configuration is loaded. It replaces the previous property source system with a more extensible model that supports importing configuration from various locations like directories, JAR files, or even Kubernetes volumes.
In practice, this means your application.properties or application.yml can now use a new spring.config.import key to explicitly pull in additional config files. The old spring.config.location behavior is now deprecated. This change makes configuration more predictable and easier to trace, especially in complex cloud environments.
What are the updates for Docker and cloud deployment?
Spring Boot 2.4 makes building efficient Docker images a first-class citizen. The Spring Boot Maven and Gradle plugins now directly support building layered Docker images using Cloud Native Buildpacks without any custom configuration.
You can simply run ./mvnw spring-boot:build-image to create an optimized, production-ready OCI image. This matters because it drastically reduces the effort required to containerize your application and follows modern cloud-native practices. The support for volume mounts also simplifies configuring secrets in platforms like Kubernetes.
How does 2.4 improve application lifecycle?
Graceful shutdown is now enabled by default for all embedded web servers. When a shutdown signal is received, the web server will stop accepting new requests and wait for existing requests to complete before shutting down.
Health groups have also been enhanced, allowing you to create custom aggregations of health indicators for different deployment scenarios. For instance, you can define a "readiness" group that only includes database and disk checks, which is perfect for Kubernetes liveness probes.
What about Spring Cloud integration changes?
The way Spring Boot initializes the Spring Cloud context has been redesigned. The bootstrap.yml file and the spring-cloud-starter-bootstrap dependency are no longer required by default.
Instead, you can now enable the bootstrap context with the spring.cloud.bootstrap.enabled=true property or through the spring.config.import mechanism. This cleanup reduces magic and makes the integration between Boot and Cloud more explicit and easier to debug.
FAQ
Why is my application failing to start after upgrading to 2.4?
This is likely due to the new configuration processing. Check if you were using spring.config.location with specific files; you need to replace it with spring.config.import. Also, ensure any custom profiles activate correctly under the new rules.
Do I need to change my Docker build process?
Your existing process will still work, but you should consider switching to the new built-in build-image goal. It creates optimized, layered images that start faster and have a smaller footprint compared to traditional Dockerfile approaches.
What happened to my bootstrap.yml file?
The bootstrap context is now disabled by default. If you need it for Spring Cloud Config, you must add the spring-cloud-starter-bootstrap dependency and set spring.cloud.bootstrap.enabled=true, or use the new spring.config.import=configserver: syntax.
How do the health group changes affect my Kubernetes probes?
Health groups give you more control. You can now define a specific group for your liveness probe that excludes slow-checking indicators, making your probes more reliable and preventing unnecessary pod restarts.
Is the legacy configuration processing completely removed?
No, it's deprecated but still available. You can set spring.config.use-legacy-processing=true to temporarily revert to the old behavior. However, you should migrate to the new model as the legacy support will be removed in a future release.