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

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写反(这里要明白两者的区别)