I want to intercept requests in my Spring Boot app which I have configured below. But I don't want to intercept requests from Swagger / Actuator. I know I can use excludePathPatterns but I don't want to use that as I don't want to maintain a list of exclusions. Can anyone tell me why addPathPatterns isn't sufficient?
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(requestInterceptor)
.addPathPatterns("/endpoint1", "/endpoint2");
}
I fixed it by replacing my config class (no need to excludePathPatterns):
@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {
with
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {