SpringBoot整合Mybatis無法掃描xml文件的解決
網(wǎng)上說是使用idea在SpringBoot整合Mybatis時(shí)候會(huì)掃描不到xml文件
1.將xml文件放在resources下
2.在application.properties中配置xml文件的掃面
補(bǔ)充知識(shí):Springboot整合mybatis /*.xml路徑URl does not exist問題
解決一:
在配置文件下 掃描不到 xml文件:
原來的文件:
<bean class='org.mybatis.spring.SqlSessionFactoryBean'> <property name='dataSource' ref='dataSource'/> <!-- 自動(dòng)掃描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'/> <!-- 自動(dòng)掃描mapping.xml文件 --> <property name='mapperLocations' value='classpath*:com/qinkangdeid/mapping/*.xml'/></bean>
解決二:
war包里面缺少M(fèi)apper對(duì)應(yīng)的xml文件,也就是沒有把xml文件打包進(jìn)去。解決辦法是,在pom.xml文件中的build標(biāo)簽中添加如下代碼,顯示的強(qiáng)制將xml文件打到war包中:
<resources> <resource> <directory>src/main/java</directory> <includes><include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources>
以上這篇SpringBoot整合Mybatis無法掃描xml文件的解決就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. jsp實(shí)現(xiàn)登錄驗(yàn)證的過濾器2. Xml簡(jiǎn)介_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理3. phpstudy apache開啟ssi使用詳解4. ASP.NET MVC使用異步Action的方法5. 利用ajax+php實(shí)現(xiàn)商品價(jià)格計(jì)算6. 爬取今日頭條Ajax請(qǐng)求7. jsp文件下載功能實(shí)現(xiàn)代碼8. ajax實(shí)現(xiàn)頁(yè)面的局部加載9. uni-app結(jié)合.NET 7實(shí)現(xiàn)微信小程序訂閱消息推送10. AJAX的跨域問題解決方案
