What’s New in Spring Boot 2.4.0? Key Features and Migration Guide
Spring Boot 2.4.0 introduces a brand‑new configuration file handling system, updates core dependencies, deprecates legacy APIs, and changes default servlet registration, while still supporting Java 8‑15 and offering migration paths for older versions, making it essential reading for Java backend developers.
Preface
Spring Boot 2.4.0 Official Release
Note: the 2.4.0 version does not have a .RELEASE suffix; it follows Spring's latest version naming scheme.
Spring Boot 2.4.0 is the first release that uses the new version scheme. Compared with the previous 2.3.0.RELEASE, the gap is about half a year.
Generally, a minor version upgrade brings many updates and improvements. As a test subject, I tried the new version first.
Version Support
Besides the newly released 2.4.0, the 2.3.x/2.2.x branches are still
actively maintained
. Spring Boot follows the Pivotal OSS support policy, providing three years of support for a major version from its release date.
Details:
- 2.3.x: supported version, released in 2020‑05, currently the active mainline.
- 2.2.x: supported version, released in 2019‑10, currently the active mainline.
- 2.1.x: released in 2018‑10, supported until the end of 2020‑10; upgrade is recommended.
EOL branches
:
- 2.0.x: released in 2018‑03, maintenance stopped on 2019‑04‑03.
- 1.5.x: final 1.x branch, released in 2017‑01, maintenance stopped on 2019‑08‑01.
Recap of 2.3.x Features
1. Graceful shutdown
: the server stops accepting new requests and waits for ongoing requests to finish within a configurable timeout ( spring.lifecycle.timeout-per-shutdown-phase=xxx, default 30s).
2. Configuration file location supports wildcards
: you can separate MySQL and Redis configurations into different files, e.g., /config/mysql/application.properties and /config/redis/application.properties (only works for classpath‑outside resources).
3. Core dependency upgrades
:
3.1 Spring Data Neumann (now renamed to Spring Data 2020.0.0)
3.2 Spring Session Dragonfruit (old naming)
3.3 Spring Security 5.3
3.4 Spring Framework remains at 5.2.x (no upgrade)
3.5 Bean Validation: spring-boot-starter-web no longer brings validation automatically; add spring-boot-starter-validation if needed.
3.6 Manual inclusion of Bean Validation is recommended due to its wide usage.
3.7 Minor version upgrades usually ignore new features.
After the recap, start the journey with Spring Boot 2.4.0.
Key New Features in 2.4.0
2.4.0.1 New Configuration File Handling (properties/yaml)
This is the most heavyweight change: the loading logic of configuration files has been rewritten to simplify and rationalize external configuration loading, potentially breaking backward compatibility.
Simple application.properties or application.yml files upgrade seamlessly.
Complex files such as application-profile.properties / application-profile.yml or Spring Cloud Config, multi‑YAML files with separators, require explicit migration.
Because configuration files are part of the program, special migration guidance is provided.
2.4.0.2 Migration Guide for Legacy Configuration Properties
Older versions (pre‑2.4.0) are considered “legacy”. Spring Boot updates the handling of application.properties / application.yml and introduces the spring.config.import property.
Option 1: Restore legacy mode (not recommended)
: add spring.config.use-legacy-processing=true to the environment (e.g., in application.properties). spring.config.use-legacy-processing = true This makes Spring Boot revert to the old ConfigFileApplicationListener processing, which is deprecated and will be removed in Spring Boot 2.6.0.
Option 2: Migrate to the new rules (recommended)
: apply changes when using multi‑document YAML, external configuration files, or spring.profiles entries.
Key points: the new configuration loading is not backward compatible; you must adapt your setup accordingly.
2.4.0.3 Removal of Vintage Engine from spring‑boot‑starter‑test
Since Spring Boot 2.2.0, JUnit 5 is the default test library. The Vintage Engine, which allowed JUnit 4 tests to run on JUnit 5, is removed in 2.4.0. If you still need JUnit 4 support, manually add the junit-vintage-engine dependency.
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>2.4.0.4 Embedded Database Detection
The detection now only treats databases that run entirely in memory as embedded. For file‑based or server‑mode databases, you must configure username ( spring.datasource.username=sa) and initialization mode ( spring.datasource.initialization-mode).
2.4.0.5 Logback Configuration Property Renames
Logback property names have been renamed for clarity, e.g., logging.pattern.rolling-file-name → logging.logback.rollingpolicy.file-name-pattern. A new class LogbackLoggingSystemProperties extends the previous LoggingSystemProperties. Deprecated properties will be removed in future releases.
2.4.0.6 DefaultServlet No Longer Registered
Spring Boot 2.4.0 stops registering DefaultServlet by default; the DispatcherServlet now handles the root path. If your application depends on the default servlet, enable it with server.servlet.register-default-servlet=true.
private void addDefaultServlet(Context context) {
Wrapper defaultServlet = context.createWrapper();
defaultServlet.setName("default");
defaultServlet.setServletClass("org.apache.catalina.servlets.DefaultServlet");
defaultServlet.addInitParameter("debug", "0");
defaultServlet.addInitParameter("listings", "false");
defaultServlet.setLoadOnStartup(1);
defaultServlet.setOverridable(true);
context.addChild(defaultServlet);
context.addServletMappingDecoded("/", "default");
}In modern Spring MVC applications, static resources are served by DefaultServletHttpRequestHandler, making the explicit DefaultServlet unnecessary.
2.4.0.7 HTTP Traces No Longer Include Cookie Headers
By default, cookie and Set‑Cookie headers are omitted from HTTP trace data. To retain them, configure
management.trace.http.include=cookies,errors,request-headers,response-headers.
static {
Set<Include> defaultIncludes = new LinkedHashSet<>();
defaultIncludes.add(Include.REQUEST_HEADERS);
defaultIncludes.add(Include.RESPONSE_HEADERS);
defaultIncludes.add(Include.TIME_TAKEN);
DEFAULT_INCLUDES = Collections.unmodifiableSet(defaultIncludes);
}2.4.0.8 Neo4j Support Changes
Before 2.4.0, only spring.data.neo4j properties existed. Starting with 2.4.0, a new spring.neo4j prefix is introduced and the old Neo4jDataProperties class is added.
@ConfigurationProperties(prefix = "spring.neo4j")
public class Neo4jProperties { ... }
@ConfigurationProperties(prefix = "spring.data.neo4j")
public class Neo4jDataProperties { ... }Other Upgrade Considerations
Spring Framework 5.3 is used as the core framework in Spring Boot 2.4.0.
Spring Data 2020.0 is the data layer version.
The release fully supports Java 15 while maintaining a minimum of Java 8.
When using constructor binding, property names must match parameter names, which can be problematic with Java reserved keywords.
@ConfigurationProperties(prefix = "sample")
public class SampleConfigurationProperties {
private final String importValue;
public SampleConfigurationProperties(@Name("import") String importValue) {
this.importValue = importValue;
}
}Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
