public class TestStudent {
@Test
public void test01(){
try {//加载配置文件
InputStream in = Resources.getResourceAsStream("config/mybatis-config.xml");
//获取sqlSession对象
SqlSession sqlSession = new SqlSessionFactoryBuilder().build(in).openSession();
//查询所有学生信息
List<Student> students = sqlSession.selectList("cn.kgc.mybatis.dao.StudentDao.getAll");
students.forEach(student -> System.out.println(student) );
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void test02(){//查询一个学生信息
try {//加载配置文件