1. 程式人生 > >關於spring boot自動注入出現Mapper Consider defining a bean of type 'xxx' in your configuration問題解決方案

關於spring boot自動注入出現Mapper Consider defining a bean of type 'xxx' in your configuration問題解決方案

問題:

Mapper註解不能被識別,
Consider defining a bean of type 'XXX' in you configuration

參考其他部落格得到如下解決辦法:
在指定的application類上加上這麼一行註解,手動指定application類要掃描哪些包下的註解

@SpringBootApplication(scanBasePackages = {"com.example"})  

但是這樣會導致其他註解沒有被識別到,輸入多個引數後又和原來的錯誤一樣了。

解決辦法:

application類上加上:

@MapperScan(value = "com.example.demo.mapper")

參考:
https://blog.csdn.net/a532672728/article/details/77702772