先在 mapper.xml 中创建一个 mapper:

<mapper namespace="TestMapper">  
    <select id="selectStudent" resultType="Map">  
        select * from student  
    </select>  
</mapper>

类型选择 Map。然后在对应的 TestMapper.java 接口中创建抽象方法:

public interface TestMapper {  
    List<Map> selectStudent();  
}

之后在主函数中调用即可生成:

try (SqlSession sqlSession = MybatisUtil.getSqlSession(true)){  
    //暂时还没有业务  
    TestMapper testMapper = sqlSession.getMapper(TestMapper.class);  
    List<Map> student = testMapper.selectStudent();  
    student.forEach(System.out::println);  
}