关于#spring boot#的问题:springboot 2.3.7 整合swagger 1.9.0 报错启动类有注解yml文件(语言-java)

springboot 2.3.7 整合swagger 1.9.0 报错
启动类有注解
yml文件
去掉启动类上的@EnableSwaggerDoc2就不会报错,但是进不去swagger的ui界面

img

img

img

不知道你这个问题是否已经解决, 如果还没有解决的话:
  • 这个问题的回答你可以参考下: https://ask.csdn.net/questions/674297
  • 这篇博客你也可以参考下:springboot整合swagger2报错
  • 除此之外, 这篇博客: springboot之spring-boot 2.3.x 整合swagger3.0.0中的 2.2、swagger的配置类 部分也许能够解决你的问题, 你可以仔细阅读以下内容或者直接跳转源博客中阅读:
    /**
     * 基于Swagger生成API文档
     * @EnableOpenApi:启动OpenApi的类; 之前是@EnableSwagger2
    
     */
    @Configuration
    @EnableOpenApi
    public class SwaggerConfiguration {
    
        @Bean
        public Docket createRestApi() {
            return new Docket(DocumentationType.OAS_30).apiInfo(apiInfo()).select()
                    .apis(RequestHandlerSelectors.basePackage("com.badger.spring.boot.web")).paths(PathSelectors.any())
                    .build();
        }
    
        private ApiInfo apiInfo() {
            return new ApiInfoBuilder().title("我是标题").description("我是描述").contact(new Contact("联系人", "www.baidu.com", "286279186@qq.com"))
                    .version("1.0").build();
        }
    
    }
    

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^