Springを使用してOpen API DocおよびOpen 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]
なぜそれが起こっているのか手がかりはありますか?
私は同じ問題を抱えていました、ここで完全なスタックトレース:
24-12-2019 15:51:45.312 [restartedMain] ERROR o.s.boot.SpringApplication.reportFailure - Application run failed
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)
at org.springframework.boot.autoconfigure.AutoConfigurationSorter$AutoConfigurationClass.getOrder(AutoConfigurationSorter.Java:204)
at org.springframework.boot.autoconfigure.AutoConfigurationSorter$AutoConfigurationClass.access$000(AutoConfigurationSorter.Java:150)
at org.springframework.boot.autoconfigure.AutoConfigurationSorter.lambda$getInPriorityOrder$0(AutoConfigurationSorter.Java:62)
at Java.util.TimSort.countRunAndMakeAscending(TimSort.Java:355)
at Java.util.TimSort.sort(TimSort.Java:234)
at Java.util.Arrays.sort(Arrays.Java:1512)
at Java.util.ArrayList.sort(ArrayList.Java:1462)
at org.springframework.boot.autoconfigure.AutoConfigurationSorter.getInPriorityOrder(AutoConfigurationSorter.Java:61)
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector$AutoConfigurationGroup.sortAutoConfigurations(AutoConfigurationImportSelector.Java:430)
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector$AutoConfigurationGroup.selectImports(AutoConfigurationImportSelector.Java:415)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGrouping.getImports(ConfigurationClassParser.Java:878)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.Java:801)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.Java:771)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.Java:185)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.Java:315)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.Java:232)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.Java:275)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.Java:95)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.Java:705)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.Java:531)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.Java:140)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.Java:742)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.Java:389)
at org.springframework.boot.SpringApplication.run(SpringApplication.Java:311)
at org.springframework.boot.SpringApplication.run(SpringApplication.Java:1213)
at org.springframework.boot.SpringApplication.run(SpringApplication.Java:1202)
at com.test.server.Application.main(Application.Java:45)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:62)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.Java:49)
Caused by: Java.io.FileNotFoundException: class path resource [org/springdoc/core/MultipleOpenApiSupportConfiguration.class] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.Java:180)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.Java:51)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.Java:103)
at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.createMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.Java:86)
at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.getMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.Java:73)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.Java:81)
at org.springframework.boot.autoconfigure.AutoConfigurationSorter$AutoConfigurationClass.getAnnotationMetadata(AutoConfigurationSorter.Java:229)
... 32 common frames omitted
問題は、互換性のないバージョンのspringdoc-openapi-core
およびspringdoc-openapi-ui
ライブラリにあります。両方の依存関係に1.1.49バージョンを設定することで修正しました。
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-core</artifactId>
<version>1.1.49</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.1.49</version>
</dependency>