1. 程式人生 > >Could not autowire. No beans of 'Mapper' type found.

Could not autowire. No beans of 'Mapper' type found.

首先你要判斷是的是否注入進來了

一種是我沒有注入進來報錯(執行報錯)

第二種是注入進來了,可以正常執行,但是這個紅色的提示看著看著不爽

 

 

方法:

第一種是包掃描的問題

配置檔案中沒有掃描到xml,仔細檢視

sprignboot的Application中沒有掃描dao

加上註解:@MapperScan("com.xxx.dao")

 

 

第二種

可以修改警告的範圍(但是不太想改)

可以在mapper上加上@Repository註解