1 String resource = "mybatis-config.xml"; 2 InputStream inputStream = null; 3 try { 4 // 获取SqlSessionFactory 5 inputStream = Resources.getResourceAsStream(resource); 6 SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(inputStream); 7 // 获取SqlSession 8 SqlSession session = factory.openSession(); 9 try {10 //method111 //Student student = session.selectOne("cn.cgq.demo.mybatis.mapper.StudentMapper.selectStudent", 10);12 //method213 StudentMapper mapper=session.getMapper(StudentMapper.class);14 Student student=mapper.selectStudent(new Long(10));15 //输出结果16 System.out.print