解决Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘inteController‘

出现这个错也可能会出现项目无法启动的错误。完整错误是

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'recureController' method

一、错误出现原因

        controller层出现了重复的方法映射

        

        可以看到图片中两个方法的映射是一样的,这是问题所在

解决方法也很简单,既然已经知道了问题所在那么解决起来也很简单,只需要将重复的方法映射修改即可

二、另外,项目无法启动,一般存在配置错误。像我们常用的xml,或者是控制层的错误,在这里说几个常见的原因

1.        mapper.xml文件里出现了空的namespace路径(无法连接dao层)

2.        mapper.xml文件里有重复的方法名

3.        将resultMap和resultType写反(这里要明白两者的区别)

 

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
扎眼的阳光的头像扎眼的阳光普通用户
上一篇 2023年12月14日
下一篇 2023年12月14日

相关推荐