开发者社区> 问答> 正文

把项目的spring版本从3.0升级到3.2之后,其中一个controller报奇怪的错误?报错

jboss5.1

报错信息如下

17:18:10,987 ERROR [DispatcherServlet] Context initialization failed 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'communicationController' bean method 
public int site.lbt.controller.CommunicationController.repeatChatRequest(site.lbt.bean.Direction,site.lbt.bean.User)
to {[],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'communicationController' bean method 
public boolean site.lbt.controller.CommunicationController.sendFollow(site.lbt.bean.Follow,site.lbt.bean.User) mapped. 

看样子说是这个controller下repeatChatRequest这个方法和sendFollow方法map重复了,但是这2个方法对应的url明显不同为啥会重复,而且不止这2个方法,同一个controller下个各个方法都是一样的问题,但是其他controller则没有问题 

顺带附上这个controller和这2个方法的声明部分 

@Controller
@SessionAttributes("user")
public class CommunicationController
@RequestMapping(method = RequestMethod.POST)
@ResponseBody
public boolean sendFollow(Follow follow, @ModelAttribute("user") User user)
@RequestMapping(method = RequestMethod.POST)
@ResponseBody
public int repeatChatRequest(Direction direction, @ModelAttribute("user") User user)

展开
收起
爱吃鱼的程序员 2020-06-22 16:48:43 565 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    RequestMapping注解中没看到你的url信息

    2020-06-22 16:49:01
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
云栖社区特邀专家徐雷Java Spring Boot开发实战系列课程(第20讲):经典面试题与阿里等名企内部招聘求职面试技巧 立即下载
微服务架构模式与原理Spring Cloud开发实战 立即下载
阿里特邀专家徐雷Java Spring Boot开发实战系列课程(第18讲):制作Java Docker镜像与推送到DockerHub和阿里云Docker仓库 立即下载

相关实验场景

更多