以下在springBoot配置文件中配置:带有下划线的表字段映射为驼峰格式的实体类属性
# 解决mysql表字段和实体类属性名不对应的问题,比如mysql中使用的是 user_id,在实体类中写的是userId,这个配置会自动转化
mybatis.configuration.map-underscore-to-camel-case=true
数据库表字段:
create table user(
user_id int(11) not null
);
实体类:
class Person {
private Integer userId;
}
mapper.xml配置文件:
<mapper>
<select >
select user_id from user
</select>
</mapper>