基于上一篇文章https://blog.csdn.net/fly7765/article/details/100077895,如果想把mapper.xml文件放在resources目录下,那么在application.properties中添加一行即可
mybatis.mapper-locations=classpath:/mapper/entities/mapper/*.xml
路径为:
其中,需要注意的几点是
- 路径前用/
- 全路径一定要写对
- 用/进行分隔
- mapper的接口和XML两个的文件名要相同
- namespace要对应上(有些eclipse可以点击是可以跳转的)
- 如果要加载多个目录下的xml,用逗号进行分隔