1. 准备 pojo 类
2. 准备对应的 mapper 类
3. 准备 xxxmapper.xml,namespace 属性指向 mapper 路径, 用于写复杂的 sql 语句
4. 配置 applicationContext.xml
1)Context:component 扫描
2)Context:annotation-config(激活注解)
3) 读取配置文件, 获取数据源, 扫描 mapper.xml 文件
4) 交给 spring 来管理会话工厂
扫描 mapper(实现 sqlsession.getmapper())
完事
来源: http://www.bubuko.com/infodetail-3077959.html