Springboot 掃描mapper接口的2種操作
在所有mapper接口使用@Mapper注解
@Mapper (將包中的所有接口都標注為DAO層接口)public interface UserMapper { UserInfo getUserInfo(@Param('userId') String userId);}方式二:
在springboot的啟動類使用@MapperScan注解
(作用:將指定包中的所有接口都標注為DAO層接口,相當于在每一個接口上寫@Mapper)
@SpringBootApplication@MapperScan(basePackages = 'com.xiami.springboot.sbootdemo.mapper')public class SbootdemoApplication { @Autowired private ApplicationArguments applicationArguments; public static void main(String[] args) { SpringApplication.run(SbootdemoApplication.class, args); } }
補充:spring boot掃描多個mapper文件夾
1、今天在做項目的時候報錯(Invalid bound statement (not found):
com.reportSystem.dao.ReprotSystemDao.findTotalDrawCount)
2、最后排查問題,總以為是contorller或者service層出的問題,仔細比較過后發(fā)現(xiàn)還是一樣的效果,怎么改都報錯。
3、最后發(fā)現(xiàn)是配置文件掃描mapper文件夾下的mapper出現(xiàn)的問題,在此記錄一下。

實在是自己粗心大意了。

4、修改application文件中的mapper配置的路徑就好!
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持好吧啦網(wǎng)。如有錯誤或未考慮完全的地方,望不吝賜教。
相關(guān)文章:
1. ASP基礎知識VBScript基本元素講解2. Python3 json模塊之編碼解碼方法講解3. python 使用事件對象asyncio.Event來同步協(xié)程的操作4. 使用Python webdriver圖書館搶座自動預約的正確方法5. Python 合并拼接字符串的方法6. Python字符串到字節(jié)的轉(zhuǎn)換。雙反斜杠問題7. Linux刪除系統(tǒng)自帶版本Python過程詳解8. Python sublime安裝及配置過程詳解9. ASP.NET MVC使用jQuery ui的progressbar實現(xiàn)進度條10. python為什么叫爬蟲?

網(wǎng)公網(wǎng)安備