Springdoc openapi和Sping Boot parent 2.7.10兼容性

xpszyzbs  于 5个月前  发布在  Spring
关注(0)|答案(1)|浏览(85)

我将我的应用程序spring-boot-starter-parent版本升级到2.7.10。

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.10</version>
</parent>

<properties>
   <java.version>1.8</java.version>
<properties>

字符串
沿着,我将我的应用程序集成到OpenApi中,并添加了如下依赖项

<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-ui</artifactId>
    <version>1.6.8</version>
    <type>pom</type>
</dependency>


在此之后,我可以访问我的swagger here http://localhost:8080/v3/api-docs,但我可以看到它作为JSON响应。为了获得典型的swagger ui页面,我建议在删除springdoc-openapi-ui的同时添加下面的依赖项

<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
    <version>2.0.0</version>
</dependency>


我甚至尝试使用下面的依赖关系,但我得到了同样的错误

<dependency>
        <groupId>org.springdoc</groupId>
        <artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
        <version>2.0.0</version>
    </dependency>


下面是我的Swagger配置类

@Bean
public OpenAPI customOpenAPIConfig() {
    return new OpenAPI().info(buildInfo());
}

private Info buildInfo() {
    return new Info()
            .title("WTS-Config Shipper Preferences API")
            .description("Shipper Preference API to create rules");
}


现在,当我在本地运行应用程序时,

Caused by: java.lang.UnsupportedClassVersionError: org/springdoc/core/conditions/MultipleOpenApiSupportCondition has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0


我的项目目前正在使用Java 1.8,我在IntelliJ IDEA中运行这个应用程序,我确保所有设置都设置为Java8,包括编译器等。
我的目标是使用Swagger UI访问应用程序:http://localhost:8080/swagger-ui.html

kse8i1jr

kse8i1jr1#

springdoc-openapi-starter-webmvc-uispringdoc-openapi-starter-webmvc-api依赖项只支持JDK17SpringBoot3.x。如果你想使用SpringBoot2.x,请使用springdoc-openapi-ui依赖项。

相关问题