title: ResourceHandler conflict with wildcards in Controllers
body: <p>I'm trying to reserve all paths starting with <code>/static/**</code> for a resource handler.
  Unfortunately, I have some wildcards deriving out of the root path <code>/</code> in request mappings. Something like this:</p>
  
  <p><a href="https://i.stack.imgur.com/FCwfs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FCwfs.png" alt="Preview"></a></p>
  
  <p><strong>What did I try?</strong></p>
  
  <ul>
  <li><p><code>ResourceHandlerRegistry#setOrder</code>:</p>
  
  <pre><code>@Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
      registry.addResourceHandler("/static/**")
              .addResourceLocations("classpath:/resources/static/");
  
      registry.setOrder(1);
  }
  </code></pre></li>
  <li><p>Various versions of interceptor (with or without order):</p>
  
  <pre><code>@Override
  public void addInterceptors(InterceptorRegistry registry) {
      registry.addInterceptor(new ResourcesInterceptor())
              .excludePathPatterns("/static/**")
              .order(2);
  }
  </code></pre></li>
  </ul>
  
  <p>That is a half-hearted success (probably it won't even work if I change mapping to <code>/{profile}/{project}/**</code>), because:</p>
  
  <pre><code>/static/style/home.css      # works
  /static/style/home.cssxxx   # 404, works
  /static/style               # catched by controller, expected: 404
  /static                     # catched by controller, expected: 404
  </code></pre>
  
  <p>I've found some similar questions, mostly unanswered or with a little dirty solutions, like:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/41725343/spring-boot-mvc-request-mapping-overrides-static-resources">Exclude manually <code>static</code> path in every controller with wildcard by regex</a></li>
  <li>Change your mappings</li>
  <li><a href="https://stackoverflow.com/questions/27293043/spring-register-handler-method-dependening-on-order-annotation">Manage controllers order</a></li>
  <li>Create dedicated controller pointed to <code>/static/**</code> </li>
  <li>[...]</li>
  </ul>
  
  <p>Summary:</p>
  
  <ul>
  <li>I don't want to use regex, because it will be painful in the future</li>
  <li>I also can't change mappings. I know, that it is the simplest way, but I'm just not able to do that.</li>
  <li>Changing an order not working</li>
  <li>Creating dedicated controller still have some issues with paths</li>
  </ul>
  
  <p>I'm looking for a simple soulution, fully automated and preferably from the configuration. The question is: <strong>what's the proper way to achieve that?</strong></p>