【问题标题】:Integrating Swagger with Spring 3.0.6.RELEASE将 Swagger 与 Spring 3.0.6.RELEASE 集成
【发布时间】:2017-06-21 07:34:38
【问题描述】:

我当前的项目是基于 Spring 3.0.6.RELEASE (Spring rest) 的 maven,我正在尝试将 swagger 与我的项目集成,但我遇到了依赖问题,也没有从 swagger 网站上找到足够的文档。

我在 pom.xml 文件中使用了以下依赖项。

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>3.0.6.RELEASE</version>
</dependency>
<dependency>
   <groupId>com.mangofactory</groupId>
   <artifactId>swagger-springmvc</artifactId>
   <version>0.5.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>[${jackson.databind-version}]</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
<version>[${jackson.databind-version}]</version>
</dependency>

您能否请人帮忙找到与 Spring 3.0.6.RELEASE 集成的正确依赖项,因为在将战争部署到服务器时低于异常。

org.apache.catalina.core.StandardContext listenerStart SEVERE:
Exception sending context initialized event to listener instance of class
org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error
creating   bean with name 'documentationController': Injection of
autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not 
autowire field: private
SEVERE: Context initialization failedjava.lang.NoClassDefFoundError:
org/springframework/web/bind/support/WebDataBinderFactory at
java.lang.Class.getDeclaredMethods0(Native Method) at
java.lang.Class.privateGetDeclaredMethods(Unknown Source) at
java.lang.Class.getDeclaredMethods(Unknown Source) at
org.springframework.core.type.StandardAnnotationMetadata.has‌​
AnnotatedMethods(Sta‌​ndardAnnotationMetad‌​ata.java:136)

注意:我们有很好的 spring 4.X 版本的文档,但 Spring 3.0.6 版本没有。

【问题讨论】:

  • 你遇到了什么问题??
  • 请更新您的问题并在此处添加完整的异常堆栈跟踪并删除上述 cmets..
  • 嗨,凯,更新了有例外的问题,请检查。

标签: spring maven swagger swagger-ui spring-rest


【解决方案1】:

请打开您的 pom.xml 并单击 Dependency Hierarchy 选项卡并检查您的 swagger 依赖项需要哪个版本的 spring mvc。请查看以下屏幕截图以供参考:

例如,在这种情况下,swagger-springmvc vesion 1.0.0 指的是 tp spring-web 和 spring-webmvc 版本 3.2.9.RELEASE。

在您的情况下,如果依赖层次结构中存在一些冲突,请检查并尝试解决冲突。

【讨论】:

    猜你喜欢
    • 2020-01-21
    • 1970-01-01
    • 2021-09-19
    • 2019-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-20
    • 2020-06-24
    相关资源
    最近更新 更多