mybatis执行流程

//通过配置文件取到sqlSessionFactory
String resource = "mybatis-config.xml";
InputStream inputStream = null;
try {
inputStream = Resources.getResourceAsStream(resource);
} catch (IOException e) {
e.printStackTrace();
}
sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
//通过sqlSessionFactory取到sqlSession
sqlSession = sqlSessionFactory.openSession().getSqlSession();
//通过sqlSession取到对应的mapper
userMapper = sqlSession.getMapper(UserMapper.class);
上一篇:20.05.03学习记录


下一篇:Mybatis中重要组件的生命周期