=============== MyBatis查询全部 =============== public interface StudentDao { ... // 查询全部 public List all(); ... } ... ... 若实体类的属性名与对应字段的字段名不同,可以用属性名作为对应字段的别名。 ... ... 或者通过resultMap标签指定字段和属性的映射关系。 ... ... ... ... public class StudentDaoTest { ... // 测试查询全部 @Test public void testAll() { try { // SQL会话 SqlSession session = new SqlSessionFactoryBuilder() .build(Resources.getResourceAsStream("mybatis-config.xml")) .openSession(); // 数据访问对象 StudentDao dao = session.getMapper(StudentDao.class); // 查询全部 List students = dao.all(); // 打印全部 for (Student student : students) System.out.println(student); } catch (IOException e) { e.printStackTrace(); } } ... } 例程:HelloMyBatis