Spring Boot MVC Configuration
Replace the removed WebMvcConfigurerAdapter with WebMvcConfigurer and retain Spring Boot's MVC auto-configuration.
@EnableWebMvc
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(
ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("home");
}
}
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(
ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("home");
}
}
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.
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.