1.解决属性名和字段名不一致的问题
public class User { private int id; private String name; private String password;解决方法: 方法一 简单暴力1、起别名
// select * from mybatis.user where id=#{id} //类处理器 // select id, name,pwd as password from mybatis.user where id=#{id}2、ResultMap 结果映射集
id,name,pwd id,name,password <!--结果集映射--> <resultMap id="UserMap" type="User"> <!-- column数据库中字段property 实体类中字段 --> <result column="id" property="id"/> <result column="name" property="name"/> <result column="pwd" property="password"/> </resultMap> <select id="getUserById" parameterType="int" resultMap="UserMap"> select * from mybatis.user where id=#{id} </select> </mapper>