【发布时间】:2019-07-24 18:12:31
【问题描述】:
我和here 有同样的问题。我想将 swagger 集成到 非 Spring Boot 项目中。我按照使用 springfox 的答案here 中给出的步骤操作,但在服务器启动时出现以下错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter': Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cachingModelPropertiesProvider' defined in URL [jar:file:*/WEB-INF/lib/springfox-schema-2.9.2.jar!/springfox/documentation/schema/property/CachingModelPropertiesProvider.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'optimized': Failed to introspect bean class [springfox.documentation.schema.property.OptimizedModelPropertiesProvider] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/classmate/members/ResolvedParameterizedMember
这些是添加的依赖项:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
更新: 所以我想我错过了杰克逊 fastxml 依赖项。我用 pom.xml 来回移动,错误就消失了。仍在尝试将导致问题的确切依赖归零。
虽然这个错误消失了,但又弹出了一个:
org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is com.google.common.util.concurrent.ExecutionError: java.lang.NoSuchMethodError: com.google.common.collect.FluentIterable.concat(Ljava/lang/Iterable;Ljava/lang/Iterable;)Lcom/google/common/collect/FluentIterable;
于是我切换到 springfox 的 2.6.1 版本,第二个错误消失了,我得到了一个很好的干净服务器启动。
【问题讨论】:
-
你能发布你的 pom.xml 吗?
-
我认为问题来自另一个丢失的 jar ,你能发布你的 pom.xml 吗?
-
我已经更新了帖子。