Appearance
能正常启动项目,但打开
http://localhost:8080/swagger-ui/index.html 报404错误;
输入其它网址,也会跳转到这个网址,再报404错误;
解决方法:
- 删除所有
spingfox相关的包; - 删除所有
swagger相关的包; - 删除所有
knife4j相关的包; Application.yml中也不要配置任何内容;- 关键好像是在
configuration中,删除所有配置,只留下MybatisPlusConfig之前有个WebMvcConfig配置,好像删除就正常了;暂时不知道这些配置起什么作用;
package com.mincheng.construction.configuration; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; @Configuration public class WebMvcConfig extends WebMvcConfigurationSupport {
/** * 发现如果继承了WebMvcConfigurationSupport,则在yml中配置的相关内容会失效。 需要重新指定静态资源
*/ @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/").addResourceLocations( "classpath:/static/"); registry.addResourceHandler("/").addResourceLocations( "classpath:/static/"); registry.addResourceHandler("swagger-ui.html", "doc.html").addResourceLocations( "classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations(
"classpath:/META-INF/resources/webjars/");
super.addResourceHandlers(registry);
} }
