在 WebSecurity
的配置类中设置放行swagger相关资源
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring()
.antMatchers("/v2/api-docs", "/swagger-resources/configuration/ui",
"/swagger-resources","/swagger-resources/configuration/security",
"/swagger-ui.html","/css/**", "/js/**","/images/**", "/webjars/**", "**/favicon.ico", "/index"
);
}
}
添加之后再运行
http://localhost:9001/swagger-ui.html 就可以访问了
来源:oschina
链接:https://my.oschina.net/u/4270607/blog/4406292