数据库字段和JavaBean字段名不一致解决办法
数据库字段
u_name
JavaBean字段userName
Mabtis–>Mapper解决
一、取别名
<select id="finfAll" resultType="com.bealei.springboot.domain.User">
select u_id userId,u_name userName,u_pswd userPassword from tb_user
</select>
二、使用ResulMap
<resultMap id="myMap" type="com.bealei.springboot.domain.User">
<id column="u_id" property="userId"/>
<result column="u_name" property="userName"/>
<result column="u_pswd" property="userPassword"/>
</resultMap>
<select id="findAll" resultMap="myMap">
select u_id,u_name,u_pswd from tb_user
</select>
三、开启驼峰命名自动转换
<settings>
<setting name="mapUnderscoreToCamelCase " value="true"/>
</settings>