I\'m trying to register an instance of HandlerInterceptor in Spring using Java Config without extending WebMvcConfigurationSupport. I\'m c
Just stating @Blauhirn's comment, WebMvcConfigurerAdapter is deprecated as of version 5.0:
Deprecated as of 5.0
WebMvcConfigurerhas default methods (made possible by a Java 8 baseline) and can be implemented directly without the need for this adapter
Refer to the new way to do it:
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new MyCustomInterceptor())
// Optional
.addPathPatterns("/myendpoint");
}
}
Plus, as stated here, do not annotate this with @EnableWebMvc, if you want to keep Spring Boot auto configuration for MVC.