目录
一、Mybatis中XxxMapper.xml文件位置
1、放在resources/mappers目录下
1.1、普通mybatis案例中
在核心配置文件mybatis-config.xml中设置映射文件位置
<!--引入映射文件,可以通过package或者mapper标签设置-->
<mappers>
<!--<package name=""/>-->
<mapper resource="mappers/UserMapper.xml"/>
</mappers>
1.2、springboot中
application.yml文件中添加配置:
mybatis:
mapper-locations: classpath:mappers/*.xml
2、放在resources/com/xxx自定义接口同名的目录下
mybatis案例中和springboot中都是一样的,只要目录名和包名相同
3、放在src/main/java/com/xxx/mapper接口相同包下
需要在pom.xml中添加如下内容
<build>
<resources>
<resource>
<!-- 打包带上 -->
<directory>src/main/java</directory>
<includes>
<!-- 任意目录下的*.xml-->
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
越努力,越幸运!
codefishyyf与你一起努力!