0

I had Swagger (2.7.0) properly configured and working fine together with Spring Boot (1.5.4) but after I added custom class extending DelegatingWebMvcConfiguration (used to configure own RequestMappingHandlerAdapter) Swagger stopped being displayed with the below WARN message:

 o.s.w.s.PageNotFound | No mapping found for HTTP request with URI [<swagger_page.html>] in DispatcherServlet with name 'dispatcherServlet'

I'm wodering why.

m52509791
  • 449
  • 5
  • 13
  • 1
    When extending `DelegatingWebMvcConfiguration` you are disabling the Spring Boot auto configuration for the web classes possibly breaking things. – M. Deinum Jan 03 '18 at 12:55
  • Are you sure? - Everything else works fine, hm. – m52509791 Jan 03 '18 at 12:56
  • Yes I'm sure... Wy did you need to extend it? Generally when doing things like this you are doing things you shouldn't be doing (or using the framework in away you shouldn't be using it). – M. Deinum Jan 03 '18 at 12:56
  • Thanks. Is there a smart way to have both: Spring Boot auto config and `DelegatingWebMvcConfiguration` extended? – m52509791 Jan 03 '18 at 13:01
  • Long story short: I had to register custom `HandlerMethodArgumentResolver` - the one that deals with annotations (e.g @RequestParameter) not the regular custom ones which will be be triggerd for such arguments. – m52509791 Jan 03 '18 at 13:10
  • What is it that that needs to do? If you want to further configure the `RequestMappingHandlerAdapter` just register a `BeanPostProcessor` which does just that. – M. Deinum Jan 03 '18 at 13:20
  • Generally `BeanPostProcessor` approach would work but not for this case. I need to change `RequestMappingHandlerAdapter.argumentResolvers` list and class api does not support that. – m52509791 Jan 03 '18 at 13:28
  • You should register a custom resolver which you can quite easily add. – M. Deinum Jan 03 '18 at 13:30
  • Custom resolver will not work with annotations, moreover I want that resolver to be triggered first. – m52509791 Jan 03 '18 at 13:31

1 Answers1

0

I had this problem and added this to the DelegatingWebMvcConfiguration

@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("swagger-ui.html")
            .addResourceLocations("classpath:/META-INF/resources/");

    registry.addResourceHandler("/webjars/**")
            .addResourceLocations("classpath:/META-INF/resources/webjars/");
}

as described on http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api config without springmvc which in this case seems like it's being overridden.

Alternatively you could extend WebMvcConfigurerAdapter and just change what you need that way the default configs for other things remain untouched