1.注解在接口上实现
@Select("select * from mybatis.user where id = #{id}")
List<User> findUserById(int id);
2.需要在核心配置文件中绑定接口
<!--绑定接口-->
<mappers>
<mapper class="com.pireua.dao.UserMapper"/>
</mappers>
3.测试
本质:反射机制实现
底层:动态代理!
Mybatis详细流程图
原文:https://www.cnblogs.com/Pireua/p/15240002.html