You bump the Spring Boot version to 4, run the build, and the main code compiles fine. Then the tests fail with a wall of errors like these:
cannot find symbol
symbol: class MockBean
package org.springframework.boot.test.autoconfigure.web.servlet does not exist
The test code itself is fine. Spring Boot 4 removed @MockBean and @SpyBean, split the test starter into one starter per technology, and moved the slice annotations like @WebMvcTest and @DataJpaTest to new packages.
Once you know the new names, the fixes are mostly search and replace. Below is each one, shown on a small Books app with three tests that pass on Spring Boot 4.1.2.
The app under test
A Book entity, a repository, a service and a controller with one endpoint:
`@RestController
@RequestMapping("/books")
public class BookController {
private final BookService service;
public BookController(BookService service) { this.service = service; }
@GetMapping("/{id}") public Book get(@PathVariable long id) { return service.get(id);β¦