Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2020-01-28 11:25:13.592 ERROR[main]org.springframework.boot.SpringApplication.reportFailure:845 -Application run failed
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 ‘contractHumanController’ method
public com.xtj.utils.Result<java.lang.Object> com.xtj.controller.ContractHumanController.update(com.xtj.pojo.ContractHuman)
to {[/contracthuman/update],methods=[POST]}: There is already ‘contractHumanController’ bean method
从提示信息中可以看出是controller层中的错误,但是翻译错误后又看不出是什么错误,就是说某个bean不能被注入啥了,仔细的检查了一下controller层后发现错误原因

在复制的过程中不小心写了2个相同的名字的controller方法,但是由于修改了传入参数,它还不报错,难受啊,只要将requestMapping中的值和方法名更换了,重启之后正常运行。
本文详细解析了在SpringBoot项目中遇到的启动失败问题,具体表现为因控制器方法映射冲突导致的Bean创建异常。通过调整@RequestMapping注解的值和方法名称,成功解决了问题并恢复正常运行。
1124

被折叠的 条评论
为什么被折叠?



