When I use spring.resources.add-mappings autoconfigure, at the same time registe a interceptor which 'PathPattern' is not mapping to a controller. That cause the interceptor not be invoked. The error message just like this.

No handler found for POST /interceptUrl

So I have to write a controller that receive '/interceptUrl' request. And this resolve my problem finally. Version: 2.1.11.RELEASE

spring.resources.add-mappings=false
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(myInterceptor)
                .addPathPatterns("/interceptUrl");
    }

Comment From: bclozel

A Spring MVC HandlerInterceptor intercepts calls that are mapped to handlers. If no handler is mapped for a particular request, then the interceptor is never called.

You'll find more information about this behavior in this Spring Framework issue comment. This is the expected behavior for this feature, so I'm closing this issue now.

Depending on your use case, interceptors might still be the best choice, or a plain Servlet filter might be a better option here.

Thanks!