版權聲明:本文爲 小異常 原創文章,非商用自由轉載-保持署名-註明出處,謝謝!
本文網址: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
中所有的映射路徑吧!