Cannot map 'XXXController.Create' bean method

【转 :http://www.fanfanyu.cn/news/staticpagefile/2351.html】 

最近在开发项目的过程中SpringMVC抛了个“Ambiguous mapping found. Cannot map 'clientPoolController' bean method”异常出来,如下(只列出重要的部分,以免篇幅过长):

   org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'clientPoolController' bean method

   ......

   at java.lang.Thread.run(Thread.java:745)

   Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'clientPoolController' bean method

   根据上述异常情况,分析得出一下结论:

    1. bean重复初始化:使用@controller注解初始化一次,在applicationContext中又定义一次。

     注:我通过对项目对应配置文件查找,发现并没有重复初始化的情况。

    2. 在不同的Controller中定义的映射重复。

     注:项目中clientPoolController与clientController是继承关系,clientPoolController继承clientController。所以重点查找了报错的clientPoolController和clientController发现映射都一致,发现问题所在。

   解决方案:

    注释掉clientPoolController中的@Controller标签即可。

   运行测试成功,OK问题解决!

    3. 调查发现在同一个controller中url映射出现重复。

原文地址:https://www.cnblogs.com/jpfss/p/9007910.html