MyBatis根据Dao中的接口,创建一个dao接口的实现类,并创建这个类的对象
这样的话就只需要接口,不用写实现类了。
image.png

使用动态代理实现增删改查

  1. SqlSession sqlSession = MyBatisUtils.getSqlSession();
  2. StudentDao dao = sqlSession.getMapper(StudentDao.class);
  3. List<Student> students = dao.selectStudents();
  4. for(Student stu : students) {
  5. System.out.println(stu);
  6. }