No mapping for GET /swagger-ui.html

这是在@EnableWebMvc的注释之下,原先swagger2的默认地址失效了,所有需要重新配置

在SwaggerConfig配置类中继承 WebMvcConfigurer,重写addResourceHandlers方法

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {

registry.addResourceHandler("/**").addResourceLocations(
"classpath:/static/");
registry.addResourceHandler("swagger-ui.html").addResourceLocations(
"classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations(
"classpath:/META-INF/resources/webjars/");
WebMvcConfigurer.super.addResourceHandlers(registry);

}

阅读剩余
THE END