配置之映射器说明
映射器(Mappers)
MapperRegistry:注册绑定我们的Mapper文件
方式一:[推荐使用]
<!--每一个Mapper.xml都需要在mybatis核心配置文件中注册!-->
<mappers>
<mapper resource="com/tian/dao/UserMapper.xml"/>
</mappers>
方式二:使用class文件绑定注册
<!--每一个Mapper.xml都需要在mybatis核心配置文件中注册!-->
<mappers>
<mapper class="com.tian.dao.UserMapper"/>
</mappers>
注意点:
- 接口和他的Mapper配置文件必须同名!
- 接口和他的Mapper配置文件必须在同一个包下!
方式三:使用扫描包进行注入绑定
<mappers>
<package name="com.tian.dao"/>
</mappers>
注意点:
- 接口和他的Mapper配置文件必须同名!
- 接口和他的Mapper配置文件必须在同一个包下!

被折叠的 条评论
为什么被折叠?



