SpringBoot整合Mybatis⽆法扫描xml⽂件的解决
⽹上说是使⽤idea在SpringBoot整合Mybatis时候会扫描不到xml⽂件
1.将xml⽂件放在resources下
2.在application.properties中配置xml⽂件的扫⾯
补充知识:Springboot整合mybatis /*.xml路径URl does not exist问题
解决⼀:
在配置⽂件下扫描不到 xml⽂件:
原来的⽂件:
<bean id="sqlSessionFactory" class="batis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<!-- ⾃动扫描l⽂件 -->
<property name="mapperLocations" value="classpath:com/qinkangdeid/mapping/*.xml"/>
</bean>
修改classpath 为 classpath*
<bean id="sqlSessionFactory" class="batis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<!-- ⾃动扫描l⽂件 -->
spring怎么读取xml文件<property name="mapperLocations" value="classpath*:com/qinkangdeid/mapping/*.xml"/>
</bean>
解决⼆:
war包⾥⾯缺少Mapper对应的xml⽂件,也就是没有把xml⽂件打包进去。解决办法是,在l⽂件中的build标签中添加如下代码,显⽰的强制将xml⽂件打到war包中:
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
以上这篇SpringBoot整合Mybatis⽆法扫描xml⽂件的解决就是⼩编分享给⼤家的全部内容了,希望能给⼤家⼀个参考,也希望⼤家多多⽀持。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。