mappers标签引入映射器的四种方式
2024-08-27 18:57:08
第一种方式: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>
最新文章
- D3.js部署node环境开发
- Android 添加cookie
- linux cpuInfo
- CSS_css sprite原理优缺点及使用
- Windows2008当桌面使用
- linux中如何查看进程对应的cpu使用情况?
- 【JAVA - SSM】之MyBatis逆向工程的使用
- MFC实现多风格真彩色大图标工具栏按钮
- div中显示某个网页
- 十件你需要知道的事,关于openstack-trove(翻译)
- Mysql中给有记录的表添加唯一索引
- php 慢配置文件
- SOAPdenovo组装软件使用记录
- 201772020113李清华《面向对象程序设计(java)》第一周学习总结
- jQuery操错题积累
- C#单例类的实现
- 第11月第8天 ffmpeg ffplay
- Gym - 101020H Weekend floyd+next_permutation
- IDEA如何初始化Git本地仓库,并提交到远程仓库
- codevs 2147 数星星
热门文章
- Python的进阶:copy与deepcopy区别
- GrADS,NCL一些经验
- 经典笔试题:用C写一个函数测试当前机器大小端模式
- flask中的宏
- 【转】新装的CentOS 7安装python3
- Java中 static、final和static final的特点及区别
- react-native ListView 性能问题
- 转载---LIBRARY_PATH和LD_LIBRARY_PATH环境变量的区别
- 通过exp命令对Oracle数据库进行备份操作(提供两种情况的备份:备份本地,备份远程的数据库)
- Daily Scrum1 11.3