版权声明:本文为 小异常 原创文章,非商用自由转载-保持署名-注明出处,谢谢! 本文网址:https://blog.csdn.net/sun8112133/article/details/107056269
最近在玩 Spring Boot 的时候,启动项目时报了个 There is already 'xxxController' bean method 的错误,网上查询相关资料才知问题所在,特此总结,如果能帮助到你那就再好不过了。
报错信息
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 'helloController' method
报错原因及解决方式
通过报错信息大概能看出是 Controller 出错了。其实报这个错的原因是因为你 Controller 里的 @RequestMapping 中的映射路径有重复了,再好好检查一下这个 xxxController 中所有的映射路径吧!
博客中若有不恰当的地方,请您一定要告诉我。前路崎岖,望我们可以互相帮助,并肩前行!