NoSuchMethodError 使用 spring 框架 [英] NoSuchMethodError using spring framework

查看:78
本文介绍了NoSuchMethodError 使用 spring 框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用类似 spring 的应用程序容器,但在运行时出现以下错误:

i'm using spring like application container and I'm getting the following error at runtime:

   Caused by: java.lang.NoSuchMethodError: org.springframework.http.MediaType.compareTo(Lorg/springframework/http/MediaType;)I
at org.springframework.web.servlet.mvc.condition.ProducesRequestCondition.compareMatchingMediaTypes(ProducesRequestCondition.java:273)
at org.springframework.web.servlet.mvc.condition.ProducesRequestCondition.compareTo(ProducesRequestCondition.java:218)
at org.springframework.web.servlet.mvc.method.RequestMappingInfo.compareTo(RequestMappingInfo.java:217)
at org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping$1.compare(RequestMappingInfoHandlerMapping.java:77)
at org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping$1.compare(RequestMappingInfoHandlerMapping.java:75)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MatchComparator.compare(AbstractHandlerMethodMapping.java:367)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MatchComparator.compare(AbstractHandlerMethodMapping.java:358)
at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
at java.util.TimSort.sort(TimSort.java:220)
at java.util.Arrays.sort(Arrays.java:1512)
at java.util.ArrayList.sort(ArrayList.java:1454)
at java.util.Collections.sort(Collections.java:175)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lookupHandlerMethod(AbstractHandlerMethodMapping.java:261)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:223)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:56)
at org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:298)
at org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1091)
at org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1076)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:896)

这是我的依赖树

[INFO] +- pdftron:pdftron:jar:6.6.1:compile
[INFO] +- edu.yale:its.tp.cas.client.dto:jar:3.1.0:compile
[INFO] +- log4j:log4j:jar:1.2.16:compile
[INFO] +- org.apache.openejb:javaee-api:jar:5.0-1:provided
[INFO] +- javax.servlet:jstl:jar:1.2:provided
[INFO] +- javax.servlet.jsp:jsp-api:jar:2.1:provided
[INFO] +- org.springframework:spring-core:jar:4.1.4.RELEASE:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.springframework:spring-expression:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-beans:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:4.1.4.RELEASE:compile
[INFO] |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-context:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-context-support:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-oxm:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc-portlet:jar:4.1.4.RELEASE:compile
[INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.5:compile
[INFO] |  \- org.codehaus.jackson:jackson-core-asl:jar:1.9.5:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.19:compile
[INFO] +- org.springframework:spring-test:jar:4.1.4.RELEASE:test
[INFO] +- org.springframework.security:spring-security-core:jar:3.2.0.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-web:jar:3.2.0.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-config:jar:3.2.0.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-taglibs:jar:3.2.0.RELEASE:compile
[INFO] |  \- org.springframework.security:spring-security-acl:jar:3.2.0.RELEASE:compile
[INFO] +- commons-dbcp:commons-dbcp:jar:1.3:compile
[INFO] +- org.hibernate:hibernate-core:jar:3.6.9.Final:compile
[INFO] |  +- antlr:antlr:jar:2.7.6:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  +- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:3.6.9.Final:compile
[INFO] |  \- javassist:javassist:jar:3.12.0.GA:compile
[INFO] +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO] +- org.hibernate:hibernate-validator:jar:4.2.0.Final:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.1:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.6.1:compile
[INFO] +- javax.validation:validation-api:jar:1.0.0.GA:compile
[INFO] +- cglib:cglib-nodep:jar:2.2.2:compile
[INFO] +- javax.transaction:jta:jar:1.1:compile
[INFO] +- commons-pool:commons-pool:jar:1.5.6:compile
[INFO] +- commons-digester:commons-digester:jar:2.1:compile
[INFO] |  \- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO] +- commons-fileupload:commons-fileupload:jar:1.2.2:compile
[INFO] +- javax.servlet.jsp.jstl:jstl-api:jar:1.2:compile
[INFO] +- org.glassfish.web:jstl-impl:jar:1.2:compile
[INFO] +- javax.el:el-api:jar:1.0:provided
[INFO] +- joda-time:joda-time:jar:1.6:compile
[INFO] +- commons-codec:commons-codec:jar:1.6:compile
[INFO] +- org.apache.tiles:tiles-jsp:jar:2.2.2:compile
[INFO] |  +- org.apache.tiles:tiles-servlet:jar:2.2.2:compile
[INFO] |  |  \- org.apache.tiles:tiles-core:jar:2.2.2:compile
[INFO] |  \- org.apache.tiles:tiles-template:jar:2.2.2:compile
[INFO] |     \- org.apache.tiles:tiles-api:jar:2.2.2:compile
[INFO] +- commons-io:commons-io:jar:2.3:compile
[INFO] +- commons-lang:commons-lang:jar:2.6:compile
[INFO] +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] +- jsptags:pager-taglib:jar:2.0:compile
[INFO] +- org.owasp.esapi:esapi:jar:2.1.0:compile
[INFO] |  +- commons-configuration:commons-configuration:jar:1.5:compile
[INFO] |  +- commons-beanutils:commons-beanutils-core:jar:1.7.0:compile
[INFO] |  +- xom:xom:jar:1.2.5:compile
[INFO] |  +- org.beanshell:bsh-core:jar:2.0b4:compile
[INFO] |  \- org.owasp.antisamy:antisamy:jar:1.4.3:compile
[INFO] |     +- org.apache.xmlgraphics:batik-css:jar:1.7:compile
[INFO] |     |  +- org.apache.xmlgraphics:batik-ext:jar:1.7:compile
[INFO] |     |  \- org.apache.xmlgraphics:batik-util:jar:1.7:compile
[INFO] |     \- net.sourceforge.nekohtml:nekohtml:jar:1.9.12:compile
[INFO] \- junit:junit:jar:3.8.1:test

我哪里做错了?

推荐答案

您正在使用混合版本的 Spring.spring-security-web 3.2.0.Release 依赖于 spring-web 3.2.6.Release.您应该尽可能更新所有 spring 依赖项以使用单一版本.

You're using mixed versions of Spring. spring-security-web 3.2.0.Release depends on spring-web 3.2.6.Release. You should update all of your spring dependencies to use a single version where possible.

https://mvnrepository.com/artifact/org.springframework.security/spring-security-web/3.2.0.RELEASE

您可以通过使用 maven 执行器插件 DependencyConvergence 规则来捕捉这样的问题:http://maven.apache.org/enforcer/enforcer-rules/dependencyConvergence.html

You can catch problems like this by using the maven enforcer plugin DependencyConvergence rule: http://maven.apache.org/enforcer/enforcer-rules/dependencyConvergence.html

这篇关于NoSuchMethodError 使用 spring 框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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