ResultMap
要解决的问题:属性名和字段名不一致
方案一:为列明指定别名,别名和java实体类的属性名一致
<select id="selectUserById" resultType="User">
select id , name , pwd as password from user where id = #{id}
</select>
方案二:使用结果集映射–>ResultMap(推荐)
<resultMap id="UserMap" type="User">
<!--column是数据库表的列名,property是对应实体类的属性名-->
<!--id为主键-->
<id column="id" property="id">
<result column="name" property="name">
<result column="pwd" property="password">
</resultMap>