将 Swagger 与 Spring 3.0.6.RELEASE 集成 [英] Integrating Swagger with Spring 3.0.6.RELEASE

查看:62
本文介绍了将 Swagger 与 Spring 3.0.6.RELEASE 集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

My current project is maven based with Spring 3.0.6.RELEASE (Spring rest) and I am trying to integrate swagger with my project but I am facing dependency issues and also not finding enough documentation from the swagger websites.

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

I have used below dependencies in pom.xml file.

<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 集成 swagger 的正确依赖项,因为在将战争部署到服务器时遇到异常.

Could you please someone help on finding the correct dependencies for integration swagger with Spring 3.0.6.RELEASE as getting below exception While deploying the war into server.

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 版本没有.

Note : We have good documentation for spring 4.X version but not on Spring 3.0.6 release.

推荐答案

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

Please open your pom.xml's and click on the Dependency Hierarchy Tab and check which version of spring mvc is required by you swagger dependency. Please look into the below screenshot for reference:

例如,在本例中,swagger-springmvc 版本 1.0.0 指的是 tp spring-web 和 spring-webmvc 版本 3.2.9.RELEASE.

For example, in this case, swagger-springmvc vesion 1.0.0 is refering tp spring-web and spring-webmvc version 3.2.9.RELEASE.

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

In your case, if there is some conflict in the Dependency Hierachy, check that out and try to resolve the conflicts.

这篇关于将 Swagger 与 Spring 3.0.6.RELEASE 集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆