Upgrading to Spring Boot 4? These five changes will break your build first. Fix them in this order and most of the red goes away.
1. The starters got split up
spring-boot-starter-web is replaced by spring-boot-starter-webmvc. The old name still works, but it is deprecated.
<!-- Spring Boot 3 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Spring Boot 4 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc</artifactId>
</dependency>Flyway and Liquibase now need their own starters: spring-boot-starter-flyway and spring-boot-starter-liquibase. Skip this and your migrations never run, with no error to tell you why.
2. Jackson 3
Jackson 3 uses tools.jackson for group IDs and packages, so imports move:
// Spring Boot 3
import com.fasterxml.jackson.databind.ObjectMapper;
// Spring Boot 4
import tools.jackson.databind.ObjectMapper;The exception is jackson-annotations. Annotations such as @JsonProperty keep their old package, com.fasterxml.jackson.annotation, so those imports stay as they are.
If you are not ready to move, Jackson 2 is still available through the deprecated spring-boot-jackson2 module.
3. @MockBean and @SpyBean are gone
Use @MockitoBean and @MockitoSpyBean instead. It is the same idea with a new home, in Spring Framework.
// Spring Boot 3
@MockBean
OrderService orderService;
// Spring Boot 4
@MockitoBean
OrderService orderService;They work on fields in your test class. They do not work inside @Configuration classes, so move any mocks you declared there into the test.
4. Undertow is removed
Undertow support is gone because it is not yet compatible with Servlet 6.1. If you used it, switch to Tomcat (the default) or Jetty.
5. New null-safety annotations
Spring now uses JSpecify annotations, for example org.jspecify.annotations.Nullable where you used to see org.springframework.lang.Nullable.
Kotlin code and null checkers may suddenly flag new errors. They are usually real gaps that were always there, so read them before you silence them.
spring-boot-starter-classic and spring-boot-starter-test-classic bring the old setup back while you migrate. Use them to get a green build, then remove them one change at a time.
The order that works
- Move to the latest 3.5.x first and fix every deprecation warning.
- Work through the five changes above.
- Run your tests, then go straight to 4.1, the version with the longest free support.
