SpringBoot项目,Swagger2文档界面无内容的可能原因

项目中引入了SpringSecurity依赖

可能的原因:

  1、API文档路径完全进不去 - 在SpringSecurity的配置类中没有设置放行文档的路径

  2、API文档界面不显示内容 - 在SpringSecurity的配置类中没有设置放行Swagger2需要的资源

附上SpringSecurity的配置类中没有设置放行的代码

 @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers(
                "/login",
                "/logout",
                "/css/**",
                "/js/**",
//                首页
                "index.html",
//                图标
                "favicon.ico",
//               swagger2
//   我引入的是第三方ui,故路径与官方不同 
                "/doc.html",
// 下面swagger2需要的一些资源
                "/webjars/**",
                "/swagger-resources/**",
                "/v2/api-docs/**"
        );
    }   
原文地址:https://www.cnblogs.com/tongsuh/p/14610104.html