问题:
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);
}

SpringBoot整合Swagger2配置详解
本文详细介绍了在SpringBoot项目中配置Swagger2时遇到的页面无法访问问题及其解决方案。当项目继承了WebMvcConfigurationSupport时,需要重新指定静态资源路径映射,以确保Swagger UI的正确加载。
1692

被折叠的 条评论
为什么被折叠?



