1、写sql语句时写别名
<select id="getUserInfoById" resultType="com.system.User">
select id,
username as userName,
password
from user
where id = #{id}
</select>
2、在map映射文件中使用resultMap类来自定义规则
<select id="getUserInfoById" resultMap="ResultMap">
select id,
user_name as userName,
password
from user
where id = #{id}
</select>
<resultMap id="ResultMap" type="com.system.user">
<id column="id" property="id" />
<result column="user_name " property="userName" />
<result column="password" property="password" />
</resultMap>