title: swagger-ui No mapping found for HTTP request
body: <p>I'm trying to document and existing Rest API a Spring MVC project (NOT spring boot!). </p>
  
  <p>My application is called <strong>api</strong> so <strong><a href="http://localhost:9090/api" rel="noreferrer">http://localhost:9090/api</a></strong> would be the root endpoint. Because I'm using spring-data-rest, on that URL I can see the json of all my exposed repositories. So far so good.</p>
  
  <p>I can also access the swagger JSON <strong><a href="http://localhost:9090/api/v2/api-docs" rel="noreferrer">http://localhost:9090/api/v2/api-docs</a></strong></p>
  
  <h3>The problem</h3>
  
  <p>I can't access the swagger-UI component on <strong><a href="http://localhost:9090/api/swagger-ui.html" rel="noreferrer">http://localhost:9090/api/swagger-ui.html</a></strong> . It gives me </p>
  
  <pre><code>WARN  org.springframework.web.servlet.PageNotFound- No mapping found for HTTP request with URI [/api/swagger-ui.html] in DispatcherServlet with name 'dispatcher'
  </code></pre>
  
  <p>Checking the spring logs when starting tomcat I can see something weird </p>
  
  <pre><code>DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory- Finished creating instance of bean 'swaggerApiListingReader'
  DEBUG org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping- Rejected bean name 'swaggerConfig': no URL paths identified
  DEBUG org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping- Rejected bean name 'swagger2Controller': no URL paths identified
  DEBUG org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping- Rejected bean name 'swaggerMediaTypeReader': no URL paths identified
  DEBUG org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping- Rejected bean name 'swaggerOperationModelsProvider': no URL paths identified
  DEBUG org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping- Rejected bean name 'swaggerOperationResponseClassReader': no URL paths identified
  DEBUG org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping- Rejected bean name 'swaggerOperationTagsReader': no URL paths identified
  DEBUG org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping- Rejected bean name 'swaggerResponseMessageReader': no URL paths identified
  DEBUG org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping- Rejected bean name 'swaggerParameterDescriptionReader': no URL paths identified
  DEBUG org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping- Rejected bean name 'swaggerExpandedParameterBuilder': no URL paths identified
  DEBUG org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping- Rejected bean name 'swaggerApiListingReader': no URL paths identified
  DEBUG org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping- Rejected bean name 'swaggerProperties': no URL paths identified
  DEBUG org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping- Rejected bean name 'springfox.documentation.swagger.configuration.SwaggerCommonConfiguration': no URL paths identified
  DEBUG org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping- Rejected bean name 'springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration': no URL paths identified
  DEBUG org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping- Rejected bean name 'swagger2Module': no URL paths identified
  </code></pre>
  
  <p>That seems to indicate the for some reason swaggerController is not associated to any URL, hence the 404 error.</p>
  
  <p>These are the version I'm working with</p>
  
  <pre><code>  &lt;spring.version&gt;4.2.8.RELEASE&lt;/spring.version&gt;
    &lt;spring-data.version&gt;Gosling-SR4&lt;/spring-data.version&gt;
    &lt;spring-data-rest&gt;2.4.6.RELEASE&lt;/spring-data-rest&gt; 
     &lt;dependency&gt;
          &lt;groupId&gt;io.springfox&lt;/groupId&gt;
          &lt;artifactId&gt;springfox-swagger2&lt;/artifactId&gt;
          &lt;version&gt;2.6.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;io.springfox&lt;/groupId&gt;
          &lt;artifactId&gt;springfox-swagger-ui&lt;/artifactId&gt;
          &lt;version&gt;2.6.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;io.springfox&lt;/groupId&gt;
          &lt;artifactId&gt;springfox-data-rest&lt;/artifactId&gt;
          &lt;version&gt;2.6.1&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>This is my Java conf. Worth pointing out that the method <em>addResourceHandlers</em>  <strong>NEVER GETS executed</strong></p>
  
  <pre><code>    @Configuration
      @EnableSwagger2
      @EnableWebMvc
  
    @Import({springfox.documentation.spring.data.rest.configuration.SpringDataRestConfiguration.class})
  public class SwaggerConfig extends WebMvcConfigurerAdapter {
      @Bean
      public Docket api() {
          return new Docket(DocumentationType.SWAGGER_2)
                  .select()
                  .apis(RequestHandlerSelectors.any())
                  .paths(PathSelectors.any())
                  .build();
      }
  
      @Override
      public void addResourceHandlers(ResourceHandlerRegistry registry) {
  
          System.out.println("******************************Configuring swagger resource handler");
          registry.addResourceHandler("swagger-ui.html")
                  .addResourceLocations("classpath:/META-INF/resources/");
          registry.addResourceHandler("/webjars/**")
                  .addResourceLocations("classpath:/META-INF/resources/webjars/");
      }
  }
  </code></pre>
  
  <p>Any suggestions? In short, swagger-ui does not work.</p>