记录mybatis接口xml配置文件的存放位置及相应方法
Mybatis的xml配置文件
通常位置
mybatis编写好mapper接口后,一般调用XXXmapper.xml的配置文件常放置在项目的resources下,并且与mapper接口的目录相关。
如:
不想在resources中新建太深目录层级
这种就需要在配置文件中指定localtion的位置
mybatis.mapper-locations=classpath:mapper/*.xml
想要把xml文件和接口文件UserMapper2放在一起
这种需要在pom.xml中节点下指定需要包括的配置文件目录
<resources>
<resource>
<!-- 打包带上 -->
<directory>src/main/java</directory>
<includes>
<!-- 任意目录下的*.xml-->
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
可以看看我的个人博客:
网站:http://www.fuzm.wang/
—————————————————————————
作为初学者,很多知识都没有掌握,见谅,如有错误请指出,以期进步,感谢!。后续有新的学习,继续补充上来。