00:00

Spring Boot 4 Migration Guide

Last updated:

The Spring Boot 4 migration guide on this page walks you through upgrading an application from Spring Boot 3.x to 4.x. Spring Boot 4 is a major release: it is built on Spring Framework 7 and Jakarta EE 11, splits its auto-configuration into many small modules with matching starters, switches to Jackson 3 and removes everything deprecated in the 3.x line. Most applications upgrade in a day or two, as long as you follow a clear order and know where the breaking changes are.

This tutorial covers what to do before upgrading, the step-by-step path including the temporary "classic" starters, the starter and package renames, the Jackson 3 changes, removed features, changes to tests and behavior, and a checklist. Examples show the before and after for a typical order service.

1. What Changed in Spring Boot 4

AreaSpring Boot 3.5Spring Boot 4
Spring Framework6.27.x
Jakarta EE / ServletJakarta EE 10 / Servlet 6.0Jakarta EE 11 / Servlet 6.1
Minimum Java1717 (the latest LTS, Java 25, is encouraged)
Auto-configurationOne large spring-boot-autoconfigure JARSmall technology modules such as spring-boot-webmvc
JSONJackson 2 (com.fasterxml.jackson)Jackson 3 (tools.jackson)
Embedded serversTomcat, Jetty, UndertowTomcat, Jetty
Null safetySpring's own annotationsJSpecify annotations
RetrySpring Retry projectBuilt into Spring Framework (@Retryable)
Mock beans in tests@MockBean (deprecated) and @MockitoBean@MockitoBean only

The rest of the Spring portfolio moved too: Spring Security 7, Spring Data 2025.1, Spring for Apache Kafka 4, Spring AMQP 4, Spring Batch 6 and others. Read their release notes for the projects you use.

2. Before You Upgrade

  1. Upgrade to the latest 3.5.x release first and make sure the build and tests are green.
  2. Remove all deprecation warnings. Everything deprecated in 3.x is gone in 4.0, so a deprecated call today is a compile error tomorrow.
  3. Check third-party dependencies that Spring Boot does not manage, such as Spring Cloud or vendor SDKs, and find their versions for Spring Boot 4.
  4. Move to a supported Java version: at least 17, preferably 25. If you use GraalVM native images, version 25 or later is required.
  5. Make sure tests cover the important paths, including JSON serialization of your API responses, because Jackson 3 changes some defaults.

3. The Migration Path Step by Step

Recommended path from Spring Boot 3.x to Spring Boot 4Start on the latest 3.5.x release and remove deprecations. Then switch the parent to Spring Boot 4 while temporarily using the classic starters and the properties migrator, which keep all auto-configuration on the classpath and report renamed properties. Fix imports, Jackson code and tests until the build is green. Then replace the classic starters with the new modular starters, add missing technology starters, remove the properties migrator and finally move to the latest 4.x release. 1. Latest 3.5.x green build, no deprecations 2. Boot 4 parent + classic starters + properties migrator 3. Fix the code imports, Jackson 3, tests, renamed properties 4. Modular starters, remove classic + migrator 5. Latest 4.x Run the full test suite after every step.
Upgrade in two steps: get it compiling with classic starters, then move to the modular starters.

3.1 Use the Classic Starters as a Stepping Stone

Spring Boot 4 offers classic starters that put all of Spring Boot's modules on the classpath, much like Spring Boot 3. They let you fix compile errors first and worry about the new module layout second:

pom.xml (temporary)
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-classic</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test-classic</artifactId>
    <scope>test</scope>
</dependency>

They replace spring-boot-starter and spring-boot-starter-test. Once the application works, remove them and add the specific starters your code needs; any missing starter then shows up as a missing class or bean.

3.2 Let the Properties Migrator Report Renamed Properties

pom.xml (temporary)
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-properties-migrator</artifactId>
    <scope>runtime</scope>
</dependency>

At startup it prints every renamed or removed property it finds and temporarily maps old names to new ones. Fix your configuration files from its report, then remove the dependency. OpenRewrite also provides automated recipes for many of these mechanical changes; review its changes like any other commit.

4. Modular Starters and Renamed Starters

Spring Boot 4 follows a strict naming convention: each technology has a module spring-boot-<technology> with root package org.springframework.boot.<technology>, a starter spring-boot-starter-<technology>, and a test starter spring-boot-starter-<technology>-test.

Spring Boot 3Spring Boot 4Note
spring-boot-starter-webspring-boot-starter-webmvcOld name deprecated
spring-boot-starter-aopspring-boot-starter-aspectjCheck whether you need it at all: only for @Aspect classes
spring-boot-starter-oauth2-clientspring-boot-starter-security-oauth2-clientSame for resource server and authorization server
spring-boot-starter-web-servicesspring-boot-starter-webservicesOld name deprecated
flyway-core or liquibase-core alonespring-boot-starter-flyway / spring-boot-starter-liquibaseTechnologies without a starter before now need one
spring-boot-starter-test onlyspring-boot-starter-webmvc-test, spring-boot-starter-data-jpa-test, ...Each test starter includes spring-boot-starter-test
RestTemplate / RestClient via the web starterspring-boot-starter-restclientDedicated starter for HTTP clients
WAR on external Tomcat: spring-boot-starter-tomcat (provided)spring-boot-starter-tomcat-runtimeFor WAR deployments

The test starters matter more than they look: for example, Spring Security's @WithMockUser needs spring-boot-starter-security-test to work properly.

5. Package Moves That Break Imports

TypeSpring Boot 3 packageSpring Boot 4 package
@EntityScanorg.springframework.boot.autoconfigure.domainorg.springframework.boot.persistence.autoconfigure
EnvironmentPostProcessororg.springframework.boot.envorg.springframework.boot (old one deprecated)
BootstrapRegistry and relatedorg.springframework.bootorg.springframework.boot.bootstrap
@WebMvcTest, @AutoConfigureMockMvcorg.springframework.boot.test.autoconfigure.web.servletorg.springframework.boot.webmvc.test.autoconfigure
TestRestTemplateorg.springframework.boot.test.web.clientorg.springframework.boot.resttestclient
@PropertyMappingorg.springframework.boot.test.autoconfigure.propertiesorg.springframework.boot.test.context

Other auto-configuration classes moved into their technology modules as well, for example org.springframework.boot.webmvc.autoconfigure. Your IDE's "organize imports" fixes most of these once the right starters are on the classpath. Spring Framework also deprecated a few names: HttpStatus.UNPROCESSABLE_ENTITY is now UNPROCESSABLE_CONTENT, and org.springframework.lang.Nullable gives way to JSpecify's org.jspecify.annotations.Nullable.

6. Upgrading to Jackson 3

Jackson 3 changed its Maven group IDs and Java packages from com.fasterxml.jackson to tools.jackson. The annotations module is the exception: @JsonProperty, @JsonIgnore and friends keep the com.fasterxml.jackson.annotation package, so most DTOs compile unchanged.

Spring Boot 3 (Jackson 2)Spring Boot 4 (Jackson 3)
com.fasterxml.jackson.databind.ObjectMappertools.jackson.databind.json.JsonMapper (auto-configured)
Defining an ObjectMapper bean replaces Boot'sDefine a JsonMapper bean instead
Jackson2ObjectMapperBuilderCustomizerJsonMapperBuilderCustomizer
@JsonComponent, @JsonMixin@JacksonComponent, @JacksonMixin
spring.jackson.read.* / spring.jackson.write.*spring.jackson.json.read.* / spring.jackson.json.write.*
Only well-known modules registeredAll Jackson modules on the classpath are registered

If default serialization differences break clients, spring.jackson.use-jackson2-defaults=true makes the auto-configured mapper behave as closely as possible like Spring Boot 3. As a last resort, the deprecated spring-boot-jackson2 module keeps Jackson 2, configured under spring.jackson2.*; plan to remove it.

7. Test Changes

Spring Boot 3Spring Boot 4
@MockBean / @SpyBean@MockitoBean / @MockitoSpyBean (Spring Framework)
@SpringBootTest provided MockMvcAdd @AutoConfigureMockMvc
@SpringBootTest provided TestRestTemplateAdd @AutoConfigureTestRestTemplate, or use the new RestTestClient with @AutoConfigureRestTestClient
@Mock / @Captor fields worked in Spring tests through a Boot listenerUse Mockito's MockitoExtension
Spock integrationRemoved

See Spring Boot testing and unit testing with JUnit and Mockito for the current style.

8. Removed Features

  • Undertow: not compatible with Servlet 6.1; switch to Tomcat or Jetty.
  • Fully executable JAR launch scripts: the embedded Unix launch script is gone; uber JARs still run with java -jar.
  • The classic uber-JAR loader: remove <loaderImplementation>CLASSIC</loaderImplementation> from your build.
  • Spring Retry dependency management: move to Spring Framework's @Retryable, or declare a Spring Retry version yourself.
  • Spring Session Hazelcast and MongoDB support in Spring Boot (now maintained by those vendors), Pulsar Reactive auto-configuration and the Spock integration.

9. Behavior Changes to Review

ChangeWhat to check
Liveness and readiness probes enabled by default/actuator/health now includes the probe groups; disable with management.endpoint.health.probes.enabled=false if unwanted
DevTools LiveReload disabled by defaultSet spring.devtools.livereload.enabled=true if you use it
Optional Maven dependencies no longer packaged in uber JARsUse <includeOptional>true</includeOptional> if needed
Logback files default to UTF-8Log shippers expecting another charset
Spring Batch runs in-memory by default with spring-boot-starter-batchUse spring-boot-starter-batch-jdbc to keep job metadata in your database
JSpecify nullability annotationsKotlin code and null checkers may report new errors
HttpMessageConverters deprecatedUse ServerHttpMessageConvertersCustomizer / ClientHttpMessageConvertersCustomizer

10. A Complete Example: Upgrading an Order Service

10.1 Build File

pom.xml (before, Spring Boot 3.5)
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.5.16</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-core</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.retry</groupId>
        <artifactId>spring-retry</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
pom.xml (after, Spring Boot 4.2)
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>4.2.0</version>
</parent>
<properties>
    <java.version>25</java.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-webmvc</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-flyway</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-webmvc-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

Spring Retry is gone because the service now uses Spring Framework's @Retryable, and the generic test starter was replaced by one test starter per technology. Depending on your database, add the Flyway database module (for example flyway-database-postgresql) as before.

10.2 Code

OrderControllerTest.java (before)
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;

@WebMvcTest(OrderController.class)
class OrderControllerTest {

    @MockBean
    OrderService orders;
    // ...
}
OrderControllerTest.java (after)
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
import org.springframework.test.context.bean.override.mockito.MockitoBean;

@WebMvcTest(OrderController.class)
class OrderControllerTest {

    @MockitoBean
    OrderService orders;
    // ...
}
JsonConfig.java (after)
package com.javabytechie.shop.config;

import org.springframework.boot.jackson.autoconfigure.JsonMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import tools.jackson.databind.SerializationFeature;

@Configuration
class JsonConfig {

    // Spring Boot 3: Jackson2ObjectMapperBuilderCustomizer with com.fasterxml.jackson imports
    @Bean
    JsonMapperBuilderCustomizer orderJson() {
        return builder -> builder.enable(SerializationFeature.INDENT_OUTPUT);
    }
}
InventoryClient.java (after)
// Spring Boot 3: org.springframework.retry.annotation.Retryable with @EnableRetry
import org.springframework.resilience.annotation.Retryable;

@Retryable(includes = ResourceAccessException.class, maxRetries = 3, delay = 200, multiplier = 2)
public StockLevel stockFor(String sku) {
    // ...
}

10.3 Configuration

application.properties (after)
# Spring Boot 3: spring.jackson.serialization.indent-output=true (still supported)
# Spring Boot 3: spring.jackson.read.* became spring.jackson.json.read.*
spring.jackson.json.read.allow-trailing-comma=true

Startup with the properties migrator still on the classpath lists any remaining renamed keys. When the build is green and the migrator reports nothing, remove it.

11. Migration Checklist

#StepDone when
1Upgrade to the latest 3.5.x and remove deprecationsNo deprecation warnings in the build
2Upgrade Java to 17+ (preferably 25) and third-party librariesCompatible versions chosen for Spring Cloud and SDKs
3Switch the parent to 4.x, add classic starters and the properties migratorProject resolves dependencies
4Fix imports, renamed starters and Jackson 3 codeMain code compiles
5Replace @MockBean, add @AutoConfigureMockMvc where neededTests compile and pass
6Fix properties reported by the migratorMigrator reports nothing
7Replace classic starters with technology starters and test startersBuild green without classic starters
8Review behavior changes (probes, JSON output, batch metadata, Undertow)Contract tests and smoke tests pass in a test environment
9Remove the migrator, update documentation and dashboardsReady for production rollout

12. Best Practices

  • Upgrade one major version at a time: latest 3.5.x first, then 4.0 or later.
  • Separate the mechanical upgrade from feature work in its own branch and pull request.
  • Use the classic starters only as a stepping stone, and remove them before release.
  • Test JSON contracts explicitly, since Jackson 3 defaults differ from Jackson 2.
  • Prefer the new APIs over compatibility switches such as spring-boot-jackson2, which are deprecated.
  • Roll out gradually, for example one service or one canary instance first, and watch logs and metrics.

13. Summary

This Spring Boot 4 migration guide comes down to a clear order: get to the latest 3.5.x without deprecations, switch to the Spring Boot 4 parent with the classic starters and the properties migrator, fix imports, Jackson 3 code, tests and renamed properties, then move to the modular technology starters and their test starters. Watch for the removed features, notably Undertow, Spring Retry management and @MockBean, and review behavior changes such as health probes and batch metadata before going to production. Done step by step, the upgrade is mostly mechanical, and it brings Spring Framework 7, Jackson 3, built-in retries and leaner applications.

14. References