Mybatis源码解析-Mybatis初始化过程
测试方法 public class UserMapperTest { private UserMapper userMapper; SqlSession sqlSession = null; SqlSessionFactory sqlSessionFactory = null; @Before public void setUp() throws Exception { String resource = "mybatis-config.xml"; InputStream inputStream = Resources.getResourceAsStream(resource); sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream); //openSession(boolean autoCommit) 设置事务是否自动提交 sqlSession = sqlSessionFactory.openSession(true); // 获取动态代理实现类 this.userMapper = sqlSession.getMapper(UserMapper.class); } @Test public void testQueryUserById() { User user = userMapper