=============== MyBatis查询一条 =============== public interface StudentDao { ... // 查询一个 public Student one(String number); ... } ... ... public class StudentDaoTest { ... // 测试查询一个 @Test public void testOne() { try { // SQL会话 SqlSession session = new SqlSessionFactoryBuilder() .build(Resources.getResourceAsStream("mybatis-config.xml")) .openSession(); // 数据访问对象 StudentDao dao = session.getMapper(StudentDao.class); // 查询一个 Student student = dao.one("1001"); // 打印一个 System.out.println(student); } catch (IOException e) { e.printStackTrace(); } } ... } 例程:HelloMyBatis