swagger文档无法生成的坑
一、包问题
注意:找对包,并且不能是 .
而不是/
二、拦截器
设置了拦截器,记得把闸门放开:
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {
@Autowired
private AuthenticationFilter authenticationFilter;
@Override
protected void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(authenticationFilter)
// 拦截所有请求
.addPathPatterns("/**")
// 登录请求排除,不被拦截
.excludePathPatterns("/user/adminlogin")
.excludePathPatterns("/swagger-ui.html")
.excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");;
}
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
三、端口问题
这是一个很 nt 的东西,你的端口不要搞什么6666,8888之类的,拿8080就好,不然浏览器是打不开的