微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决Spring MVC加载上下文时无法识别RequestMapping批注名称属性

似乎是类路径问题。正在加载旧版本的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或更低版本不会发生此错误。有人有任何线索吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。