2014-10-16 60 views
0

我有一个应用程序,其中一个Spring @Controller注有@RequestMapping。 使用Spring(核心和webmvc)4.1.0.RELEASE或更高我在启动应用程序服务器时收到异常。Spring MVC。在加载上下文时不识别RequestMapping注释名称属性

java.lang.NoSuchMethodError: org.springframework.web.bind.annotation.RequestMapping.name()Ljava/lang/String; 
at method RequestMappingHandlerMapping.createRequestMappingInfo(RequestMapping annotation, RequestCondition<?> customCondition) 

调试,使用Eclipse检查,该方法可变annotation不包含name属性和在作用annotation.name()失败。所有其他属性值都是正确的(它们具有在Controller方法中用@RequestMapping注释的值)。

我使用的是Tomcat 7和Maven 2.3。 mvn dependency:tree不显示其他Spring版本比4.1.0.RELEASE。 使用Spring 4.0.7.RELEASE或更低版本时不会发生此错误。 有没有人有任何线索?

+0

根据消息出于某种原因它的东西名称是一种方法。你能告诉我们配置 – dimitrisli 2014-10-16 14:26:28

+0

重新检查你的所有库是相同的版本。 'RequestMapping'在'spring-web'中,而'RequestMappingHandlerMapping'在'spring-webmvc'中。 'name()'方法在4.1.0.RELEASE中添加,我相信。 – 2014-10-16 14:50:46

+0

spring-web和spring-webmvc有相同的版本。 RequestMapping中的源代码显示名称属性,但在使用Eclipse检查工具时它不会检查它。 – 2014-10-16 14:53:28

回答

0

看起来像一个类路径问题。正在加载旧版本的RequestMapping。

相关问题