Spring MVC。加载上下文时无法识别RequestMapping批注名称属性


问题内容

我有一个带有@Controller注解的Spring的应用程序@RequestMapping。使用Spring(核心和webmvc)4.1.0.RELEASE或更高版本启动应用程序服务器时出现异常。

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

使用Eclipse
inspect进行调试,方法变量annotation不包含name属性,并且操作失败annotation.name()。所有其他属性值都是正确的(它们在Controller方法中定义的值带有注释@RequestMapping)。

我正在使用Tomcat 7和Maven 2.3。 mvn dependency:tree除了4.1.0.RELEASE以外,没有显示其他Spring版本。使用Spring
4.0.7.RELEASE或更低版本不会发生此错误。有人有任何线索吗?


问题答案:

似乎是类路径问题。正在加载旧版本的RequestMapping。