I am trying to configure an interceptor in my application and I am not being able to make it work.
In my application configuration class, I have configured in the follow
I'm using Spring Boot and was having the same problem where addInterceptors()
was being called to register the interceptor, but the interceptor never fired during a request. Yet XML configuration worked no problem.
Basically, you don't need the WebMvcConfigurerAdapter
class. You just need to declare an @Bean
of type MappedInterceptor
:
@Bean
public MappedInterceptor myInterceptor()
{
return new MappedInterceptor(null, new MyInterceptor());
}