一、绝对路径引入(不推荐使用)
<mapper url="file:\\\D:\stsbundle\workplace\mybatis_demo\src\main\resources\mapper\UserMapper.xml"/>
二、相对路径引入
<mappers>
<mapper resource="mapper/UserMapper.xml"/>
</mappers>
三、mapper接口引入
注意:需要对应的mapper.xml与接口mapper处于同一包下才可以,且xml文件名与接口名要相同,xml文件中的namespace必须是对应接口的全包名
<mapper class="com.mybatis_demo.mapper.UserMapper"/>
四、package引入(要求与第三种一样,推荐使用,减少配置映射文件的步骤)
注意:当出现上面某一种引入情况时,package引入需要放在最后面
<mappers>
<package name="com.mybatis_demo.mapper"/>
</mappers>
转自:https://blog.csdn.net/ChOLg/article/details/100140484
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决