ResultMap 解决查询为null问题 1.数据库中的字段名 2.Java中实体类(pojo)设计 3.dao中的接口 //根据ID查询用户 User getUserById(int id); 4.mapper映射文件 <!--有了别名,所以这里写的是user--> <select id="getUserById" resultMap="user"> select * from mybatis.user where id = #{id} </select> 5.测试 @