MyBatis是一款优秀的持久层框架,用于简化JDBC开发。
 准备工作:
 1.导入相应的依赖在pom.xml中,比如mybatis依赖,mysql依赖,junit单元测试依赖等。
 2.编写mybatis核心配置文件(mybatis-confing.xml),要在里面写连接信息,加载sql映射文件等。
 3.编写sql映射文件(也就是你写sql语句的地方)
 4.写一个POJO(普通老式java对象) 类 ,拿来封装数据的。
//大概的使用流程:
//加载mybatis的核心配置文件,获取
	sqlSessionFactory	对象(就是连接对象的意思)
String resource = "mybatis-config.xml";	
Inputstream inputStream=Resources.getResourceAsStream(resource);	
SqlSessionFactory sqLSessionFactory = new SqlSessionFactoryBuilder().build(inputstream);
//获取sqlsession对象,用它来执行sql
SqlSession sqlSession =sqlSessionFactory.openSession();
//执行sql
List<User>users=sqlsession.selectList(“test.selectAll”);
//关闭资源
sqlsession.close();










