A Spring Boot 4 migration from 3.x goes in two moves: first get to the latest 3.5.x release (3.5.16 on Maven Central) and clear every deprecation warning, then jump straight to the current 4.x line, which is 4.1.2 as of November 2026. The work that breaks builds is predictable: renamed and split-up starters, Jackson 3's new tools.jackson packages, removed test annotations like @MockBean, Undertow's removal, and a stricter platform baseline (Java 17+, Spring Framework 7, Jakarta EE 11 with Servlet 6.1). The official tooling handles most of it: spring-boot-properties-migrator, the "classic" starters and the OpenRewrite UpgradeSpringBoot_4_0 recipe.
This guide follows the official Spring Boot 4.0 Migration Guide and puts the steps in the order that keeps your build green for as long as possible.
Where Spring Boot Stands in November 2026
Version facts first, because they decide your target. These dates come from Maven Central and the spring.io support data:
| Line | First GA | Latest patch (Nov 2026) | OSS support ends | Commercial support ends |
|---|---|---|---|---|
| 3.5.x | May 2025 | 3.5.16 (25 Jun 2026) | 2026-06-30 (ended) | 2032-06-30 |
| 4.0.x | 20 Nov 2025 | 4.0.9 (22 Oct 2026) | 2026-12-31 | 2027-12-31 |
| 4.1.x | 10 Jun 2026 | 4.1.2 (22 Oct 2026) | 2027-07-31 | 2028-07-31 |
| 4.2.x | not GA yet | 4.2.0-RC2 (5 Nov 2026) | 2027-12-31 (planned) | 2028-12-31 (planned) |
Two conclusions follow:
- Free 3.5.x support is already over. 3.5.16 is the last open-source patch. Further 3.5 fixes need a commercial subscription.
- Don't stop at 4.0. Its OSS support ends on 31 December 2026, six weeks from now. The migration guide is written for 4.0, but the upgrade cost from 4.0 to 4.1 is small (see the last section). Aim for 4.1.2, or 4.2.0 once it reaches GA. The support calendar lists the 4.2 line starting on 30 November 2026.
What Actually Changes
| Area | Spring Boot 3.5 | Spring Boot 4.x | Typical breakage |
|---|---|---|---|
| Java | 17 to 25 | 17+ (current docs list compatibility up to Java 27) | None, if you're on 17 |
| Core framework | Spring Framework 6.2 | Spring Framework 7.0 | Deprecated APIs removed |
| Jakarta EE | EE 10, Servlet 6.0 | EE 11, Servlet 6.1 | Undertow removed |
| JSON | Jackson 2 (com.fasterxml.jackson) |
Jackson 3 (tools.jackson) |
Imports, customizer names, properties |
| Starters | Few large auto-config jars | One module per technology | Missing auto-configuration at runtime |
| Testing | @MockBean, MockMvc implied |
@MockitoBean, explicit @AutoConfigureMockMvc |
Compile errors, missing beans |
| Nullability | org.springframework.lang |
JSpecify | Kotlin and NullAway builds |
| Kotlin | no 2.2 requirement | 2.2+ | Compiler plugin bump |
| Gradle | 7.6.4+ or 8.4+ | 8.14+ or 9.x | Wrapper bump |
| Native image | GraalVM 22.3+ | GraalVM 25+ | Toolchain bump |
The system requirements page for 4.1.2 lists Maven 3.6.3+, Gradle 8.14+ or 9.x, Tomcat 11.0 and Jetty 12.1 as the embedded containers, and Spring Framework 7.0.10+.
Step 1: Finish the Job on 3.5.x
The migration guide is explicit: upgrade to the latest 3.5.x first, because anything deprecated in 3.x is removed in 4.0. On 3.5 those calls only produce warnings. On 4.0 they become a hundred compile errors at once.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.16</version>
<relativePath/>
</parent>
Then make deprecations visible. With Maven, add -Xlint:deprecation to the compiler plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-Xlint:deprecation</arg>
</compilerArgs>
</configuration>
</plugin>
With Gradle (Kotlin DSL):
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.add("-Xlint:deprecation")
}
Work through every warning that points at Spring classes. Then work through three items that 3.5 already flags:
@MockBean/@SpyBean. These are deprecated in 3.4+ and removed in 4.0. Replace them now with@MockitoBean/@MockitoSpyBeanfromorg.springframework.test.context.bean.override.mockito. They work on test-class fields but not inside@Configurationclasses.- Undertow. If you use
spring-boot-starter-undertow, switch to Tomcat or Jetty on 3.5 and run your load tests there. Boot 4 has no Undertow support because Undertow isn't yet compatible with Servlet 6.1. - Unmanaged dependencies. Compare the 3.5.x and 4.0.x dependency-management pages. Anything Boot doesn't manage, such as Spring Cloud, needs an explicit compatible version. The OpenRewrite recipe below moves Spring Cloud to the 2025.1 train alongside Boot 4.0.
Ship this 3.5.16 build to production before going further. If something regresses, you want to know whether 3.5 caused it or 4.x did.
Step 2: Let OpenRewrite Do the Mechanical Work
The recipe is org.openrewrite.java.spring.boot4.UpgradeSpringBoot_4_0 in the org.openrewrite.recipe:rewrite-spring artifact. Its definition chains a lot of work:
- the 3.5 upgrade recipe;
- Spring Framework 7 and Spring Security 7 migrations;
- Spring Batch 5 to 6;
- the property renames;
@MockBeanreplacement;- web-server class relocations;
- the Hibernate, Testcontainers 2 and springdoc 3 upgrades;
- the modular-starter migration;
- adding
@AutoConfigureMockMvcand@AutoConfigureTestRestTemplatewhere needed.
Run it from a clean branch with Maven, no pom.xml changes needed (command from the OpenRewrite workshop docs):
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run \
--define rewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-spring:RELEASE \
--define rewrite.activeRecipes=org.openrewrite.java.spring.boot4.UpgradeSpringBoot_4_0 \
--define rewrite.exportDatatables=true
To preview the changes first, swap :run for :dryRun. The plugin then writes a patch file under target/rewrite/ instead of changing your sources.
With Gradle, add the plugin and recipe to build.gradle.kts, then run ./gradlew rewriteRun:
plugins {
id("org.openrewrite.rewrite") version "latest.release"
}
rewrite {
activeRecipe("org.openrewrite.java.spring.boot4.UpgradeSpringBoot_4_0")
setExportDatatables(true)
}
dependencies {
rewrite("org.openrewrite.recipe:rewrite-spring:latest.release")
}
Three caveats:
- Licensing. The recipe file is published under the Moderne Source Available License, not Apache 2.0. That's fine for running it on your own code, but check it if your legal team cares.
- It targets 4.0.x, not 4.1. Bump the version to 4.1.2 yourself afterwards.
- It doesn't port your Jackson code. The Boot recipe only rewrites a
jackson-bom.versionoverride, renaming it tojackson-2-bom.version. For imports and API changes, there is a separateorg.openrewrite.java.jackson.UpgradeJackson_2_3recipe in therewrite-jacksonartifact.
Review the result like any large PR. A side-by-side view of the old and new pom.xml or build.gradle.kts (the code difference checker works for a quick look) catches dependencies the recipe dropped or duplicated.
Step 3: Bump the Version and Catch Renamed Properties
If you skipped OpenRewrite, set the version by hand. Maven:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>4.1.2</version>
<relativePath/>
</parent>
Gradle (Kotlin DSL):
plugins {
java
id("org.springframework.boot") version "4.1.2"
id("io.spring.dependency-management") version "1.1.7"
}
Then add the properties migrator temporarily. At startup it prints every renamed or removed key and maps the old names to the new ones at runtime:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-properties-migrator</artifactId>
<scope>runtime</scope>
</dependency>
In Gradle, that's runtimeOnly("org.springframework.boot:spring-boot-properties-migrator"). Boot 4 renames are concentrated in a few areas:
| Old (3.x) | New (4.x) |
|---|---|
spring.jackson.read.* / spring.jackson.write.* (JSON features) |
spring.jackson.json.read.* / spring.jackson.json.write.* |
spring.data.mongodb.uri, .host, .port, .database |
spring.mongodb.* |
spring.session.redis.* |
spring.session.data.redis.* |
spring.dao.exceptiontranslation.enabled |
spring.persistence.exceptiontranslation.enabled |
spring.kafka.retry.topic.backoff.random |
spring.kafka.retry.topic.backoff.jitter |
One trap: in 4.1, spring.jackson.read.* and spring.jackson.write.* are valid keys again, but they now take Jackson's format-agnostic StreamReadFeature/StreamWriteFeature values. JSON-specific features (JsonReadFeature, JsonWriteFeature) belong under spring.jackson.json.*, so check each key against the type it binds to.
Remove the migrator once the startup log is clean. It's a crutch, not a compatibility layer.
Step 4: Modular Starters (the Change That Fails Silently)
Boot 4 splits auto-configuration into one module per technology, named spring-boot-<technology> with packages under org.springframework.boot.<technology>. The danger here is not a compile error. A feature can quietly stop being auto-configured because its module is no longer on the classpath.
Things that now need an explicit starter:
- Flyway and Liquibase. Previously the third-party jar alone was enough. Now you need
spring-boot-starter-flywayorspring-boot-starter-liquibase. Without it, your migrations simply don't run at startup. - Test slices. Each technology has a
-teststarter (spring-boot-starter-webmvc-test,spring-boot-starter-security-test, and so on). Those test starters pull inspring-boot-starter-testtransitively.
Several starters were renamed. The old names are deprecated but still published in 4.1.2:
| Deprecated starter | Replacement |
|---|---|
spring-boot-starter-web |
spring-boot-starter-webmvc |
spring-boot-starter-web-services |
spring-boot-starter-webservices |
spring-boot-starter-aop |
spring-boot-starter-aspectj |
spring-boot-starter-oauth2-client |
spring-boot-starter-security-oauth2-client |
spring-boot-starter-oauth2-resource-server |
spring-boot-starter-security-oauth2-resource-server |
For large codebases, the guide suggests two passes:
- Swap
spring-boot-starterforspring-boot-starter-classicandspring-boot-starter-testforspring-boot-starter-test-classic. These pull in every module, so auto-configuration behaves as it did on 3.x. Fix imports until the app runs. - Remove the classic starters and add the specific starters that your imports reveal.
Plan for the second pass. The classic starters are a migration aid, and the guide recommends moving off them.
Step 5: Jackson 3
Jackson 3 (GA since October 2025, with Boot 4.1.2 managing 3.1.7) moves group IDs and packages from com.fasterxml.jackson to tools.jackson. The one exception is jackson-annotations, which keeps its old coordinates, so @JsonProperty imports don't change. Exceptions are now unchecked: JsonProcessingException becomes JacksonException.
// Spring Boot 3.x (Jackson 2)
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
// Spring Boot 4.x (Jackson 3)
import tools.jackson.databind.json.JsonMapper;
import org.springframework.boot.jackson.autoconfigure.JsonMapperBuilderCustomizer;
Boot-specific renames:
Jackson2ObjectMapperBuilderCustomizerbecomesJsonMapperBuilderCustomizer.@JsonComponentbecomes@JacksonComponent, and@JsonMixinbecomes@JacksonMixin.JsonObjectSerializerandJsonValueDeserializerbecomeObjectValueSerializerandObjectValueDeserializer.
To replace the auto-configured mapper, define a JsonMapper bean, not an ObjectMapper bean.
Jackson 3 also changed upstream defaults. For example, it sorts properties alphabetically by default. If API consumers or snapshot tests depend on exact JSON output, set spring.jackson.use-jackson2-defaults=true to align with Boot 3 behavior.
If you can't port everything at once, for example because a library still exposes Jackson 2 types, add the deprecated bridge module. Its properties live under spring.jackson2.*:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-jackson2</artifactId>
</dependency>
Jersey users need it regardless, because Jersey 4 doesn't support Jackson 3 yet.
Step 6: Fix the Test Suite
Most of the migration's red builds come from tests:
@SpringBootTestno longer providesMockMvc. Add@AutoConfigureMockMvc.TestRestTemplateandWebTestClientare no longer provided automatically. ForTestRestTemplate, add@AutoConfigureTestRestTemplateplus thespring-boot-resttestclientandspring-boot-restclientdependencies. Its package is noworg.springframework.boot.resttestclient. The newRestTestClient(@AutoConfigureRestTestClient) is worth adopting for new tests.MockitoTestExecutionListeneris gone. If plain@Mockand@Captorfields stop being initialized, add@ExtendWith(MockitoExtension.class).
@SpringBootTest
@AutoConfigureMockMvc
class OrderControllerTest {
@Autowired
MockMvc mvc;
@MockitoBean
OrderService orderService;
}
Step 7: Null Safety and Other Gotchas
Spring Framework 7 and Boot 4 annotate their APIs with JSpecify. Plain Java builds won't notice. Kotlin projects and builds running NullAway or similar checkers may see new compile errors where a Spring API is now declared nullable. Replace org.springframework.lang.Nullable with org.jspecify.annotations.Nullable. Actuator endpoint parameters no longer honor the old annotation.
Other items from the guide that surface in production rather than at compile time:
- Spring Batch.
spring-boot-starter-batchnow runs in memory and no longer stores job metadata in your database. Usespring-boot-starter-batch-jdbcto keep restartability. - Optional Maven dependencies. These are excluded from uber jars unless you set
<includeOptional>true</includeOptional>. - Embedded launch scripts and the classic jar loader. Both are removed. Delete any
loaderImplementationCLASSICsetting. - Spring Retry. It's no longer version-managed. Pin it, or move to Spring Framework 7's built-in retry support.
- DevTools LiveReload. It's off by default (
spring.devtools.livereload.enabled=trueturns it back on) and deprecated in 4.1. - Health probes. Liveness and readiness groups are now enabled by default.
- Elasticsearch. The low-level client is now
Rest5Client. - MongoDB. There's no default UUID representation any more. Set
spring.mongodb.representation.uuid. - WAR deployments.
server.forward-headers-strategyno longer applies, so register aForwardedHeaderFilteryourself. Usespring-boot-starter-tomcat-runtime. - SBOMs. The CycloneDX Gradle plugin minimum is 3.0.0, which matters if you generate SBOMs in CI.
Some new 4.0 features are worth a look once you're upgraded:
- the
spring-boot-starter-opentelemetrystarter, which exports metrics and traces over OTLP (relevant if you're weighing OpenTelemetry against a vendor agent); - auto-configured HTTP service clients for
@HttpExchangeinterfaces; - API versioning via
spring.mvc.apiversion.*.
From 4.0 to 4.1
The 4.1 release notes are short, but these items bite:
- Removed APIs. Everything deprecated in 4.0 is gone, so clear 4.0 deprecation warnings before bumping, exactly as you did on 3.5.
- Layered jars.
layertoolsjar mode is removed. Use-Djarmode=tools. - Maven tests.
-DskipTestsno longer skips AOT processing of tests. Use-Dmaven.test.skip=true. - Gradle build info. The generated file moved to
META-INF/build-info.properties. - Constructor binding. Constructor-bound
Optionalparameters now bind toOptional.empty()instead ofnull. - jOOQ. jOOQ 3.20 requires Java 21.
4.1 also adds Spring gRPC support, @RedisListener auto-configuration and lazy JDBC connection fetching. If you use Flyway or Liquibase, re-check which tool fits now that each needs its own starter. The schema migration tools comparison covers the trade-offs.
Frequently Asked Questions
Can I upgrade directly from Spring Boot 2.7 or 3.2 to 4.x?
Not in one step. Get to Jakarta EE first (Boot 3.x), then to the latest 3.5.x with zero deprecation warnings, then to 4.x. The OpenRewrite recipe chains earlier upgrade recipes, which helps, but each hop changes runtime behavior that you need to test separately.
Do I need Java 21 or 25 for Spring Boot 4?
No. The baseline stays Java 17, and the 4.1.2 docs list compatibility up to Java 27. Moving to Java 21 or 25 LTS is still worthwhile for virtual threads and recent GC improvements, but keep it as a separate change from the Boot upgrade so you can bisect regressions.
Should I target 4.0 or 4.1?
Target 4.1.2 (or 4.2 once it's GA). 4.0.x open-source support ends on 31 December 2026, while 4.1.x is supported until 31 July 2027. The migration guide's advice is written for 4.0, but it applies to 4.1 too, plus the short list of 4.1 changes above.
Is Undertow really gone?
Yes. Spring Boot 4 removed the Undertow starter and embedded-server support because Undertow isn't yet compatible with Servlet 6.1. Switch to Tomcat 11 or Jetty 12.1 before you upgrade, and measure memory and throughput on 3.5 first.
Can I keep Jackson 2 on Spring Boot 4?
Temporarily. The deprecated spring-boot-jackson2 module restores Jackson 2 support, configured under spring.jackson2.*. Treat it as a bridge for libraries that haven't moved yet. It's a deprecated module, and Spring's policy is to remove deprecated code in later releases.
Conclusion
A Spring Boot 4 migration is mostly mechanical once you take it in the right order:
- Get to 3.5.16 and clear every deprecation.
- Run the OpenRewrite recipe on a branch.
- Bump to 4.1.2 with the properties migrator on.
- Use the classic starters only as a stepping stone.
- Port Jackson.
- Fix the tests.
Silent failures are the real risk, more than compile errors: Flyway not running without its starter, Batch losing its database metadata, a JSON field order changing. Put integration tests around those before you start. With 3.5's free support already over and 4.0's ending this year, the cheapest time to do this upgrade is now.