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)。如有錯誤或未考慮完全的地方,望不吝賜教。
相關文章:
1. 詳解Android studio 動態(tài)fragment的用法2. 基于android studio的layout的xml文件的創(chuàng)建方式3. 編程語言PHP在Web開發(fā)領域的優(yōu)勢在哪?4. 解決Android studio xml界面無法預覽問題5. 什么是python的自省6. Spring Boot和Thymeleaf整合結合JPA實現(xiàn)分頁效果(實例代碼)7. 圖文詳解vue中proto文件的函數(shù)調用8. Android如何加載Base64編碼格式圖片9. Springboot Druid 自定義加密數(shù)據(jù)庫密碼的幾種方案10. Vue封裝一個TodoList的案例與瀏覽器本地緩存的應用實現(xiàn)

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