英文:
openapi springboot - Error 'swaggerWelcome' threw exception
问题
我在我的Spring Boot项目中使用了org.springdoc的依赖项,如下所示:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.0.2</version>
</dependency>
我遇到了这个错误,可以帮助我吗?
错误信息如下:
在 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:759) 中发生错误
... 20 个公共帧被省略
由于 org.springframework.beans.factory.BeanCreationException 引发 org.springframework.beans.factory.UnsatisfiedDependencyException: 在类路径资源 [org/springdoc/webmvc/ui/SwaggerConfig.class] 中定义的名为 'indexPageTransformer' 的 bean 创建时出现了不满足的依赖关系,通过方法 'indexPageTransformer' 的参数 3 表达; 嵌套异常是 org.springframework.beans.factory.BeanCreationException: 在类路径资源 [org/springdoc/webmvc/ui/SwaggerConfig.class] 中定义的名为 'swaggerWelcome' 的 bean 创建时出现了不满足的依赖关系,通过工厂方法实例化 bean; 嵌套异常是 org.springframework.beans.BeanInstantiationException: 工厂方法 'swaggerWelcome' 引发异常; 嵌套异常是 java.lang.NoClassDefFoundError: org/springframework/http/HttpStatusCode
在 org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) 中发生错误
... 50 个公共帧被省略
由于 java.lang.NoClassDefFoundError 引发 org.springframework.beans.BeanInstantiationException: 实例化 [org.springdoc.webmvc.ui.SwaggerWelcomeWebMvc] 失败; 工厂方法 'swaggerWelcome' 引发异常; 嵌套异常是 java.lang.NoClassDefFoundError: org/springframework/http/HttpStatusCode
在 org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) 中发生错误
在 org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) 中发生错误
... 64 个公共帧被省略
由于 java.lang.NoClassDefFoundError 引发 java.lang.NoClassDefFoundError: org/springframework/http/HttpStatusCode
我尝试更改springdoc-openapi-starter-webmvc-ui的版本,但始终出现相同的错误。
英文:
i use the dependency of org.springdoc, see below in y spring boot project
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.0.2</version>
</dependency>
I have this error , can i have help ?
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:759) ~[spring-beans-5.3.23.jar:5.3.23]
... 20 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'indexPageTransformer' defined in class path resource [org/springdoc/webmvc/ui/SwaggerConfig.class]: Unsatisfied dependency expressed through method 'indexPageTransformer' parameter 3; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'swaggerWelcome' defined in class path resource [org/springdoc/webmvc/ui/SwaggerConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springdoc.webmvc.ui.SwaggerWelcomeWebMvc]: Factory method 'swaggerWelcome' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/http/HttpStatusCode
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.23.jar:5.3.23]
... 50 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springdoc.webmvc.ui.SwaggerWelcomeWebMvc]: Factory method 'swaggerWelcome' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/http/HttpStatusCode
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.23.jar:5.3.23]
... 64 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/http/HttpStatusCode
I try to change the version of springdoc-openapi-starter-webmvc-ui, but always same error
答案1
得分: 2
I got the same problem when I tried to use openapi 2.0.0 and Spring Boot 2.7. Then I found out that this version of openapi needs Spring Boot version 3 and above.
请尝试更新Spring Boot依赖版本(我假设您正在使用spring-boot-starter-web)和Spring Boot版本至3.0.0或更高。
Here's some topic I found https://170.106.8.194/repo/jhipster/jhipster-lite/issues/4351
英文:
What version of Spring Boot do you use? I got the same problem when I tried to use openapi 2.0.0 and Spring Boot 2.7. Then I found out that this version of openapi needs Spring Boot verion 3 and above.
Please try to update the Spring Boot dependencies version (I assume you're using the spring-boot-starter-web) and the Spring Boot version to be 3.0.0 or above.
Here's some topic I found https://170.106.8.194/repo/jhipster/jhipster-lite/issues/4351
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论