SpringBoot整合Mybatis無法掃描xml文件的解決
網(wǎng)上說是使用idea在SpringBoot整合Mybatis時候會掃描不到xml文件
1.將xml文件放在resources下
2.在application.properties中配置xml文件的掃面
補充知識:Springboot整合mybatis /*.xml路徑URl does not exist問題
解決一:
在配置文件下 掃描不到 xml文件:
原來的文件:
<bean class='org.mybatis.spring.SqlSessionFactoryBean'> <property name='dataSource' ref='dataSource'/> <!-- 自動掃描mapping.xml文件 --> <property name='mapperLocations' value='classpath:com/qinkangdeid/mapping/*.xml'/></bean>
修改classpath 為 classpath*
<bean class='org.mybatis.spring.SqlSessionFactoryBean'> <property name='dataSource' ref='dataSource'/> <!-- 自動掃描mapping.xml文件 --> <property name='mapperLocations' value='classpath*:com/qinkangdeid/mapping/*.xml'/></bean>
解決二:
war包里面缺少Mapper對應(yīng)的xml文件,也就是沒有把xml文件打包進去。解決辦法是,在pom.xml文件中的build標簽中添加如下代碼,顯示的強制將xml文件打到war包中:
<resources> <resource> <directory>src/main/java</directory> <includes><include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources>
以上這篇SpringBoot整合Mybatis無法掃描xml文件的解決就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. JSP+Servlet實現(xiàn)文件上傳到服務(wù)器功能2. asp讀取xml文件和記數(shù)3. JSP之表單提交get和post的區(qū)別詳解及實例4. 低版本IE正常運行HTML5+CSS3網(wǎng)站的3種解決方案5. jsp+servlet實現(xiàn)猜數(shù)字游戲6. 將properties文件的配置設(shè)置為整個Web應(yīng)用的全局變量實現(xiàn)方法7. UDDI FAQs8. ASP常用日期格式化函數(shù) FormatDate()9. HTML <!DOCTYPE> 標簽10. CSS可以做的幾個令你嘆為觀止的實例分享
