问题:

        SpringBoot配置Swagger2出现页面无法访问错误 :No mapping for GET /swagger-ui.html

解决:

        如果继承了WebMvcConfigurationSupport,则在yml中配置的相关内容会失效;需重新指定静态资源路径映射。

        在当前继承WebMvcConfigurationSupport的配置类加上如下代码:
@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/"); super.addResourceHandlers(registry);
}

技术
下载桌面版
GitHub
Gitee
SourceForge
百度网盘(提取码:draw)
云服务器优惠
华为云优惠券
腾讯云优惠券
阿里云优惠券
Vultr优惠券
站点信息
问题反馈
邮箱:[email protected]
吐槽一下
QQ群:766591547
关注微信