酷爱码 2022-10-22 15:12 采纳率: 90.9%
浏览 16
已结题

swagger3使用异常

使用springboot+springsecurity+swagger3,访问swagger地址出现异常,具体如下

img

我有给对应的路径放行

          private static final String[] URL={
            "/favicon.ico",
            "/swagger-ui/**",
            "/swagger-resources/**",
            "/v2/api-docs",
            "/v3/api-docs",
            "/webjars/**",
    };
.............................
.antMatchers(URL).permitAll()

奇怪的是/v2/api-docs能出来数据,但是/v3/api-docs不能出来数据,为什么

img

img

swagger配置类如下

@Configuration
@EnableOpenApi
public class Swagger3 {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Spring Boot Swagger3接口文档")
                .description("测测测测")
                .contact(new Contact("rgh","https://localhost","1111@qq.com"))
                .termsOfServiceUrl("https://localhost")
                .version("1.0")
                .build();
    }
}
  • 写回答

1条回答 默认 最新

  • 编号灬9527 2022-10-22 16:20
    关注

    代码搞个压缩包丢网盘看看

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 10月31日
  • 创建了问题 10月22日