我将我的应用程序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
1条答案
按热度按时间kse8i1jr1#
springdoc-openapi-starter-webmvc-ui
和springdoc-openapi-starter-webmvc-api
依赖项只支持JDK17
和SpringBoot3.x
。如果你想使用SpringBoot2.x
,请使用springdoc-openapi-ui
依赖项。