Enterprise Beginner

Replace the removed WebMvcConfigurerAdapter with WebMvcConfigurer and retain Spring Boot's MVC auto-configuration.

✕ Spring Boot 1.x
@EnableWebMvc
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
    @Override
    public void addViewControllers(
            ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("home");
    }
}
✓ Spring Boot 4.x
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(
            ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("home");
    }
}
See a problem with this code? Let us know.
🧹

No removed adapter

WebMvcConfigurer supplies default methods, so there is no adapter superclass to extend.

⚙️

Keeps Boot defaults

Without @EnableWebMvc, Spring Boot continues to configure MVC infrastructure automatically.

🎯

Override only what matters

Implement the interface and customize just the MVC hook required by the application.

Old Approach
WebMvcConfigurerAdapter with @EnableWebMvc
Modern Approach
WebMvcConfigurer with Spring Boot Auto-Configuration
Since JDK
17
Difficulty
Beginner
Spring Boot MVC Configuration
Available

Available in Spring Boot 4.0 with Spring Framework 7.0 (requires Java 17+)

Spring Boot 1.x applications commonly extended WebMvcConfigurerAdapter because Java interfaces could not provide default methods. Modern Spring Framework versions provide default implementations directly on WebMvcConfigurer, so implement the interface and override only the methods you need. In a Spring Boot application, do not add @EnableWebMvc unless you intentionally want to take full control of MVC configuration: it disables Boot's MVC auto-configuration, including its usual converters, static-resource handling, and other defaults.