WebMvcConfigurer not working in spring boot?

WebMvcConfigurer not working in spring boot?

This is mentioned in the Spring Boot Documentation, under the spring mvc section you can use WebMvcConfigurer, but you do not need to do @EnableWebMvc

So you should remove the @EnableWebMvc annotation!

@Configuration
// @EnableWebMvc Remove this!
public class ViewConfig implements WebMvcConfigurer {

@Override
public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController(/signup).setViewName(signup);
    registry.addViewController(/login).setViewName(login);
    registry.addViewController(/dashboard).setViewName(dashboard);
    registry.addViewController(/logout).setViewName(redirect:/);
}

WebMvcConfigurer not working in spring boot?

Leave a Reply

Your email address will not be published. Required fields are marked *