第一种方式:mapper标签,通过resource属性引入classpath路径的相对资源

<!-- Using classpath relative resources -->
<mappers>
<mapper resource="org/mybatis/builder/AuthorMapper.xml"/>
<mapper resource="org/mybatis/builder/BlogMapper.xml"/>
<mapper resource="org/mybatis/builder/PostMapper.xml"/>
</mappers>

第二种方式:mapper标签,通过url引入网络资源或者本地磁盘资源

<!-- Using url fully qualified paths -->
<mappers>
<mapper url="file:///var/mappers/AuthorMapper.xml"/>
<mapper url="file:///var/mappers/BlogMapper.xml"/>
<mapper url="file:///var/mappers/PostMapper.xml"/>
</mappers>

第三种方式:mapper标签,通过class属性指定mapper接口名称,此时对应的映射文件必须与接口位于同一路径下,并且名称相同

  • 如mapper接口采用注解的方式,则无需映射文件
  • windows系统下,映射文件不区分大小写,linux系统没有验证
<!-- Using mapper interface classes -->
<mappers>
<mapper class="org.mybatis.builder.AuthorMapper"/>
<mapper class="org.mybatis.builder.BlogMapper"/>
<mapper class="org.mybatis.builder.PostMapper"/>
</mappers>

第四种方式:package标签,通过name属性指定mapper接口所在的包名 ,此时对应的映射文件必须与接口位于同一路径下,并且名称相同

  • 如mapper接口采用注解的方式,则无需映射文件
  • windows系统下,映射文件不区分大小写,linux系统没有验证
<!-- Register all interfaces in a package as mappers -->
<mappers>
<package name="org.mybatis.builder"/>
</mappers>

最新文章

  1. D3.js部署node环境开发
  2. Android 添加cookie
  3. linux cpuInfo
  4. CSS_css sprite原理优缺点及使用
  5. Windows2008当桌面使用
  6. linux中如何查看进程对应的cpu使用情况?
  7. 【JAVA - SSM】之MyBatis逆向工程的使用
  8. MFC实现多风格真彩色大图标工具栏按钮
  9. div中显示某个网页
  10. 十件你需要知道的事,关于openstack-trove(翻译)
  11. Mysql中给有记录的表添加唯一索引
  12. php 慢配置文件
  13. SOAPdenovo组装软件使用记录
  14. 201772020113李清华《面向对象程序设计(java)》第一周学习总结
  15. jQuery操错题积累
  16. C#单例类的实现
  17. 第11月第8天 ffmpeg ffplay
  18. Gym - 101020H Weekend floyd+next_permutation
  19. IDEA如何初始化Git本地仓库,并提交到远程仓库
  20. codevs 2147 数星星

热门文章

  1. Python的进阶:copy与deepcopy区别
  2. GrADS,NCL一些经验
  3. 经典笔试题:用C写一个函数测试当前机器大小端模式
  4. flask中的宏
  5. 【转】新装的CentOS 7安装python3
  6. Java中 static、final和static final的特点及区别
  7. react-native ListView 性能问题
  8. 转载---LIBRARY_PATH和LD_LIBRARY_PATH环境变量的区别
  9. 通过exp命令对Oracle数据库进行备份操作(提供两种情况的备份:备份本地,备份远程的数据库)
  10. Daily Scrum1 11.3