问题
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.
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>
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(StandardAnnotationMetadata.java:136)
Note : We have good documentation for spring 4.X version but not on Spring 3.0.6 release.
回答1:
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:
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.
来源:https://stackoverflow.com/questions/44669609/integrating-swagger-with-spring-3-0-6-release