1.按照步骤一步步做,pom依赖,类配置,检查注解有无,是否冲突,路径是否正确,是否与其他路径冲突。
2.看pom依赖与sprignboot版本是否对应,一般2.2.1release 对应2.7的swagger
3.url是否是swagger-ui.html
4.看项目是否设置了其他路径
5.看资源目录是否放置正确
6.看项目是否识别到swagger的路径
如果没有添加一下内容在mvccongif中
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/statics/**").addResourceLocations("classpath:/statics/");
// 解决 SWAGGER 404报错
registry.addResourceHandler("/swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
@Configuration
public class MvcConfig implements WebMvcConfigurer {
@Bean
public LoginInterceptor createLoginInterceptor(){
return new LoginInterceptor();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(createLoginInterceptor())
.addPathPatterns("/**")
.excludePathPatterns("/crm","/index","/user/login","/css/**","/images/**","/js/**","/lib/**");
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/statics/**").addResourceLocations("classpath:/statics/");
// 解决 SWAGGER 404报错
registry.addResourceHandler("/swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
标签:总结,addResourceHandler,错误,classpath,META,registry,swagger,addResourceLocations From: https://www.cnblogs.com/flyer-ovo/p/16623009.html