mybatis配置mapper-locations位置的三種方式小結
更新時間:2023年08月07日 09:08:50 作者:8號看臺
這篇文章主要給大家介紹了關于mybatis配置mapper-locations位置的三種方式,Mybatis-Plus的初衷是為了簡化開發(fā),而不建議開發(fā)者自己寫SQL語句的,但是有時客戶需求比較復雜,需要的朋友可以參考下
方式一 xml文件與mapper類放在一起。
yml 配置
mybatis: config-location: classpath:mybatis-config.xml mapper-locations: classpath:com/example/pgsqldemo/mybatis/dao/xml/*.xml # mapper-locations: classpath:static/mybatis/mapper/*.xml
pom.xml 配置
<build> <resources> <!-- 掃描src/main/java下所有xx.xml文件 --> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> </resource> <!-- 掃描resources下所有資源 --> <resource> <directory>src/main/resources</directory> </resource> </resources> </build>
方式二 resources創(chuàng)建Mapper接口同名文件夾用來存放Mapper.xml文件(mybatis默認方式)
yml 配置
mybatis: config-location: classpath:mybatis-config.xml
方式三 在resources目錄下創(chuàng)建自定義文件夾存放
yml 配置
mybatis: config-location: classpath:mybatis-config.xml mapper-locations: classpath:/mapper/*.xml
總結
到此這篇關于mybatis配置mapper-locations位置的三種方式的文章就介紹到這了,更多相關mybatis配置mapper-locations位置內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
Mybatis 動態(tài)表名+Map參數傳遞+批量操作詳解
這篇文章主要介紹了Mybatis 動態(tài)表名+Map參數傳遞+批量操作詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-12-12關于java入門與java開發(fā)環(huán)境配置詳細教程
這篇文章主要介紹了關于java入門與java開發(fā)環(huán)境配置詳細教程,本文通過圖文并茂的形式給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-03-03