国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

SpringBoot整合Mybatis無法掃描xml文件的解決

瀏覽:2日期:2023-04-05 13:23:32

網(wǎng)上說是使用idea在SpringBoot整合Mybatis時候會掃描不到xml文件

1.將xml文件放在resources下

2.在application.properties中配置xml文件的掃面

SpringBoot整合Mybatis無法掃描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)。

標簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 横峰县| 定陶县| 凉城县| 和田市| 东山县| 自贡市| 榆社县| 夹江县| 中卫市| 云浮市| 霍山县| 辉县市| 彭阳县| 石狮市| 遂宁市| 天长市| 洞头县| 兴隆县| 南部县| 临城县| 阿克苏市| 麻江县| 辽源市| 长白| 都昌县| 陕西省| 商都县| 吴忠市| 江西省| 临武县| 阜平县| 讷河市| 兖州市| 禄丰县| 岚皋县| 乐东| 郯城县| 清徐县| 军事| 高陵县| 古交市|