A Spring Boot 4 migration is mostly three jobs: adjusting dependencies to the new modular starters,
moving JSON code from Jackson 2 to Jackson 3, and fixing tests that relied on @MockBean,
TestRestTemplate or an auto-configured MockMvc. The Java baseline stays at 17, so the JDK is
rarely the blocker. To migrate Spring Boot 3 to 4, upgrade to the latest 3.5.x first, clear the
deprecation warnings, then change the version.
The newest release is Spring Boot 4.2.0, published on 19 November 2026, with 4.1.3 and 4.0.10 as the current maintenance releases. The official migration guide is written for 4.0. The error messages below come from a small test project (Web MVC, Spring Data JPA, Flyway, three tests) moved from 3.5.16 to 4.2.0 on JDK 25.
What do you need before migrating to Spring Boot 4?
- Java 17 or later. The team encourages the latest LTS, and Boot 4.2.0 is documented as compatible up to Java 27. On Java 21 or newer, virtual threads are still one property away.
- Kotlin 2.2 or later and, for native images, GraalVM 25 or later.
- A Servlet 6.1 container. Boot 4 is based on Jakarta EE 11.
- The latest 3.5.x, with no calls to deprecated APIs. Classes, methods and properties deprecated in 3.x are removed in 4.0, and 4.1 in turn removed what 4.0 deprecated. Moving one minor version at a time lets the compiler warn you before something disappears.
- Compatible versions of what Boot does not manage, Spring Cloud for example.
Which dependency versions change?
| Dependency | Boot 4.0 (release notes) | Boot 4.2.0 (resolved in the test build) |
|---|---|---|
| Spring Framework | 7.0 | 7.1.0 |
| Hibernate ORM | 7.2 | 7.4.15 |
| Jackson | 3.0 | 3.1.8 |
| Tomcat | 11.0 | 11.0.27 |
| Jetty | 12.1 | not used |
| Jakarta Persistence | 3.2 | 3.2.0 |
| JUnit Jupiter | 6 (Framework 7 baseline) | 6.1.3 |
Spring Security 7.0, Spring Data 2025.1, Spring Batch 6.0 and Testcontainers 2.0 arrive with 4.0 as well, each with its own release notes.
Some things are gone with no replacement inside Boot:
- Undertow, because it does not support Servlet 6.1 yet. Switch to Tomcat or Jetty.
- Executable jar launch scripts and the classic uber-jar loader.
java -jarstill works. - Auto-configuration for reactive Pulsar, Spring Session Hazelcast and Spring Session MongoDB, plus the Spock integration.
- Dependency management for Spring Retry. Declare a version yourself or move to the retry support in Spring Framework 7.
What happened to the starters and auto-configuration?
Boot 4 ships many small modules in place of a few large jars. A module is named
spring-boot-<technology>, its root package is org.springframework.boot.<technology>, and its
starter is spring-boot-starter-<technology>. Each starter has a -test companion that already
brings in spring-boot-starter-test.
| Boot 3 | Boot 4 |
|---|---|
spring-boot-starter-web | spring-boot-starter-webmvc |
spring-boot-starter-aop | spring-boot-starter-aspectj |
spring-boot-starter-web-services | spring-boot-starter-webservices |
spring-boot-starter-oauth2-client | spring-boot-starter-security-oauth2-client |
spring-boot-starter-oauth2-resource-server | spring-boot-starter-security-oauth2-resource-server |
flyway-core alone | spring-boot-starter-flyway |
liquibase-core alone | spring-boot-starter-liquibase |
spring-boot-starter-batch with a database | spring-boot-starter-batch-jdbc |
The old web, web-services and oauth2 starter names still resolve in 4.2.0 but are
deprecated. The last three rows are the dangerous ones, because nothing fails at compile time. The
test project kept a bare flyway-core dependency. On Boot 4 the migrations did not run, and with
spring.jpa.hibernate.ddl-auto=validate the context failed at startup:
SchemaManagementException: Schema validation: missing table [book]
Schema validation was the only thing that made the missing migrations visible at startup. Spring Batch behaves in a similar way: the plain starter now runs in memory and stops writing job metadata to your database.
Code that imports Boot classes directly has to follow the new packages. @EntityScan, for
example, moved:
DemoApplication.java:[5,53] package org.springframework.boot.autoconfigure.domain does not exist
Its new home is org.springframework.boot.persistence.autoconfigure.EntityScan.
The classic starters as a bridge
For a large application the guide describes a two-step route. Replace spring-boot-starter with
spring-boot-starter-classic and spring-boot-starter-test with
spring-boot-starter-test-classic. That restores a classpath with every auto-configuration
module, so you can fix imports and get the application running. Then remove the classic starters
and add the specific starters that turn out to be missing.
How do you move from Jackson 2 to Jackson 3?
Jackson 3 is the default JSON library. Its packages and group IDs change from
com.fasterxml.jackson to tools.jackson. The exception is jackson-annotations, which keeps
the old package, so @JsonProperty and @JsonIgnore on your DTOs stay as they are. Code that
touches the mapper does not compile:
BookController.java:[4,38] package com.fasterxml.jackson.databind does not exist
JacksonConfig.java:[4,54] package org.springframework.boot.autoconfigure.jackson does not exist
| Boot 3 | Boot 4 |
|---|---|
Jackson2ObjectMapperBuilderCustomizer | JsonMapperBuilderCustomizer |
@JsonComponent, @JsonMixin | @JacksonComponent, @JacksonMixin |
JsonObjectSerializer | ObjectValueSerializer |
your own ObjectMapper bean | a JsonMapper (or XmlMapper) bean |
spring.jackson.parser.* | spring.jackson.json.read.* where an equivalent exists |
A customizer after the change, as compiled in the test project:
import org.springframework.boot.jackson.autoconfigure.JsonMapperBuilderCustomizer;
import tools.jackson.databind.cfg.DateTimeFeature;
@Bean
JsonMapperBuilderCustomizer isoDates() {
return builder -> builder.disable(DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS);
}
Two behaviour changes are easy to miss. Boot now registers every Jackson module it finds on the
classpath, not only the well-known ones (spring.jackson.find-and-add-modules=false turns that
off). And spring.jackson.use-jackson2-defaults=true brings the auto-configured JsonMapper
close to the Boot 3.x defaults, which helps when clients depend on the exact JSON output.
If a library still needs Jackson 2, its dependency management remains and a Jackson 2
ObjectMapper can live next to the Jackson 3 one. When you cannot migrate your own code yet, add
spring-boot-jackson2 and configure it under spring.jackson2.*. That module is deprecated from
day one, and Spring Framework plans to remove Jackson 2 support in 7.2. Jersey 4.0 has no
Jackson 3 support, so Jersey applications need this module for JSON.
What changes in tests?
| Boot 3 | Boot 4 |
|---|---|
@MockBean, @SpyBean | @MockitoBean, @MockitoSpyBean from Spring Framework |
@SpringBootTest provides MockMvc | add @AutoConfigureMockMvc |
@SpringBootTest provides TestRestTemplate | add @AutoConfigureTestRestTemplate and spring-boot-resttestclient |
spring-boot-starter-test only | one -test starter per technology, such as spring-boot-starter-webmvc-test |
@MockitoBean works on fields and on the test class, but not inside @Configuration classes.
Shared mocks move to the test class as @MockitoBean(types = {OrderService.class}). Boot’s
MockitoTestExecutionListener is removed too, so plain @Mock and @Captor fields need
Mockito’s own MockitoExtension.
Test slices changed packages along with their modules. The test project needed
org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest and
org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest. TestRestTemplate is now in
org.springframework.boot.resttestclient, and without the new annotation the context fails:
No qualifying bean of type 'org.springframework.boot.resttestclient.TestRestTemplate' available
Boot 4.2 deprecates RestTemplate and TestRestTemplate support, so new test code is better
written against RestTestClient with @AutoConfigureRestTestClient. Security tests need
spring-boot-starter-security-test for @WithMockUser to keep working.
Do the JSpecify null-safety annotations affect you?
Boot 4 and Framework 7 are annotated with JSpecify. Plain Java builds are unaffected. Kotlin
projects and builds with a null checker can see new compilation errors, because some types are
now declared nullable or non-null. Spring’s own org.springframework.lang annotations are
deprecated, and actuator endpoint parameters must use org.jspecify.annotations.Nullable to be
optional.
Which properties were renamed or changed?
| Before | After |
|---|---|
spring.dao.exceptiontranslation.enabled | spring.persistence.exceptiontranslation.enabled |
management.tracing.enabled | management.tracing.export.enabled |
spring.data.mongodb.uri, host, port, database | spring.mongodb.* |
spring.session.redis.* | spring.session.data.redis.* |
spring.kafka.retry.topic.backoff.random | spring.kafka.retry.topic.backoff.jitter |
Defaults moved as well: liveness and readiness probes are enabled, and DevTools LiveReload is
disabled. Boot 4.2 adds renames of its own, such as server.forward-headers-strategy to
server.request.header.forwarded.strategy.
Add spring-boot-properties-migrator as a runtime dependency during the migration. It prints a
report at startup and maps renamed keys temporarily:
Key: spring.dao.exceptiontranslation.enabled
Line: 4
Replacement: spring.persistence.exceptiontranslation.enabled
Treat it as a help, not a guarantee. The test project had three outdated keys, and on both 4.0.10
and 4.2.0 the report listed only this one. management.tracing.enabled and
spring.jackson.parser.allow-comments were ignored without a message, so read the configuration
changelog too. Remove the migrator when you are done.
Step-by-step migration order
- Upgrade to the latest 3.5.x and build with deprecation warnings visible.
- Replace
@MockBeanand@SpyBeanwhile still on 3.5. The replacements exist in Framework 6.2. - Check that every library Boot does not manage has a release for Boot 4.
- Set the version to the latest 4.0.x. For a large codebase, switch to the classic starters first.
- Fix the main code: Jackson imports and customizers, moved Boot packages.
- Replace renamed starters and add the new ones (Flyway, Liquibase, Batch JDBC, AspectJ).
- Fix the tests: per-technology test starters, moved slice annotations,
@AutoConfigureMockMvc. - Run with the properties migrator, update the configuration, remove the migrator.
- Drop the classic starters and
spring-boot-jackson2once nothing needs them. - Continue to 4.1 and 4.2, reading the “Upgrading from” section of each release note.
Summary
The version bump itself is one line. The work is in what that line pulls in: modules that are no longer on the classpath by accident, a JSON library with new package names, and test support that has to be requested explicitly. Compile errors are the easy part. The changes worth a deliberate check are the silent ones: migrations or batch metadata that stop being written, properties that are ignored, and JSON defaults that shift. Run the full test suite against a real schema before calling the migration done.