gpt4 book ai didi

java.lang.IllegalStateException : Unable to read meta-data for class while implementing open api with spring boot

转载 作者:行者123 更新时间:2023-12-01 22:59:11 28 4
gpt4 key购买 nike

我正在尝试在 Spring Boot 中使用 Spring 实现Open API DocOpen API UI:

我引用以下指南来执行此操作: https://www.baeldung.com/spring-rest-openapi-documentation

maven中的依赖如下:

        <!-- https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-core -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-core</artifactId>
<version>1.1.49</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-ui -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.2.20</version>
</dependency>

我使用的Spring Boot版本是2.2

通过 ./mvnw spring-boot:run 运行应用程序时遇到以下与元数据相关的错误

java.lang.IllegalStateException: Unable to read meta-data for class org.springdoc.core.MultipleOpenApiSupportConfiguration
at org.springframework.boot.autoconfigure.AutoConfigurationSorter$AutoConfigurationClass.getAnnotationMetadata(AutoConfigurationSorter.java:233) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at org.springframework.boot.autoconfigure.AutoConfigurationSorter$AutoConfigurationClass.getOrder(AutoConfigurationSorter.java:204) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at org.springframework.boot.autoconfigure.AutoConfigurationSorter$AutoConfigurationClass.access$000(AutoConfigurationSorter.java:150) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at org.springframework.boot.autoconfigure.AutoConfigurationSorter.lambda$getInPriorityOrder$0(AutoConfigurationSorter.java:63) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:360) ~[na:na]
at java.base/java.util.TimSort.sort(TimSort.java:234) ~[na:na]
at java.base/java.util.Arrays.sort(Arrays.java:1516) ~[na:na]

知道为什么会发生这种情况吗?

最佳答案

springdoc-openapi-uispringdoc-openapi-core 作为传递依赖项。最安全的做法是仅定义最深的依赖项,并让它提取其上游库的正确版本,如下所示:

<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>${springdoc-openapi-ui.version}</version>
</dependency>

换句话说,从 POM 依赖项中删除 springdoc-openapi-core,只指定上述内容(替换 ${springdoc-openapi-ui.version}当然是您想要的版本)。

关于java.lang.IllegalStateException : Unable to read meta-data for class while implementing open api with spring boot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59469357/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com