图解 https://www.malaoshi.top/show_1EF6W8rJpo61.html 的执行流程
读取mybatis总配置文件
在总配置文件中,配置了数据库信息、mapper.xml创建SqlSession 对象
通过 mapper接口 返回接口实现类对象(mybatis实现的)
调用mapper接口的方法
由于mapper.xml中 namespace 和 mapper接口全路径相匹配
<select>标签中的 id 和 mapper接口方法名相匹配
所以mybatis就调用了 mapper.xml中的sql由于
<select>标签中的 resultType 属性是 User实体类的全路径
所以查询结果封装到user对象中,然后将user对象放入到List中
返回List
