SpringBoot中集成了swagger后无法访问http://localhost:8080/swagger-ui.html
- 接上文SpringBoot集成swagger生成在线接口文档
- 点击查看上文https://blog.csdn.net/weixin_43190694/article/details/88298793
在启动类同级添加WebMvcConfig配置类
WebMvcConfig内容如下:
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/templates/**")
.addResourceLocations("classpath:/META-INF/resources/templates/");
}
}
启动springboot程序,再次访问http://localhost:8080/swagger-ui.html。