Configuring Swagger UI with Spring Boot

后端 未结 4 1169
生来不讨喜
生来不讨喜 2020-12-17 00:15

I am trying to configure Swagger UI with my Spring boot application. Although the v2/api-docs seems to be loading properly, the http://localhost:8080/swag

4条回答
  •  我在风中等你
    2020-12-17 00:56

    Add a config class like this

    @Configuration
    public class WebMvcConfiguration extends WebMvcConfigurationSupport {
    
      @Override
      public void addResourceHandlers(final ResourceHandlerRegistry registry) {
        // Make Swagger meta-data available via /v2/api-docs/
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
        // Make Swagger UI available via /swagger-ui.html
        registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/");
      }
    }
    

提交回复
热议问题