开放API Spring Boot – 错误 ‘swaggerWelcome’ 引发异常

huangapple go评论118阅读模式
英文:

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

       &lt;dependency&gt;
		&lt;groupId&gt;org.springdoc&lt;/groupId&gt;
		&lt;artifactId&gt;springdoc-openapi-starter-webmvc-ui&lt;/artifactId&gt;
		&lt;version&gt;2.0.2&lt;/version&gt;
	&lt;/dependency&gt;

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 &#39;indexPageTransformer&#39; defined in class path resource [org/springdoc/webmvc/ui/SwaggerConfig.class]: Unsatisfied dependency expressed through method &#39;indexPageTransformer&#39; parameter 3; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;swaggerWelcome&#39; 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 &#39;swaggerWelcome&#39; 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 &#39;swaggerWelcome&#39; 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

huangapple
  • 本文由 发表于 2023年5月25日 07:17:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76327950.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定