關於There is already ‘xxxController‘ bean method的報錯

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

映射路徑重複了



博客中若有不恰當的地方,請您一定要告訴我。前路崎嶇,望我們可以互相幫助,並肩前行!



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章