1.问题
接口请求后查询发现返回的部分数据为null,都是大小写字段驼峰命名的为空
[{"id":1,"userName":null,"phone":"13126789145","province":"03","userAccount":null,"userPassword":null}]
2.代码文件配置
(1)数据库设计字段为:
create table DEMO_USER
(
id NUMBER(10) not null,
user_name VARCHAR2(100),
phone VARCHAR2(30),
province VARCHAR2(50),
user_account VARCHAR2(50),
user_password VARCHAR2(50)
)
(2)对应实体:
public class DemoUserEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* $column.comments
*/
private Integer id;
/**
* $column.comments
*/
private String userName;
/**
* $column.comments
*/
private String phone;
/**
* $column.comments
*/
private String province;
/**
* $column.comments
*/
private String userAccount;
/**
* $column.comments
*/
private String userPassword;
}
(3)springboot项目配置文件 application.properties
#mybatis的相关配置
#mybatis.config-locations=classpath:mybatis/mybatis-config.xml
#mapper配置文件
mybatis.mapper-locations=classpath:mapper/*.xml
#mybatis.type-aliases-package=com.beiluo.demo.entity
3.解决方案
添加配置如下
#开启驼峰命名 处理下划线映射到实体
#mybatis.configuration.map-underscore-to-camel-case=true
最后springboot项目配置文件 application.properties为
#mybatis的相关配置
#mybatis.config-locations=classpath:mybatis/mybatis-config.xml
#mapper配置文件
mybatis.mapper-locations=classpath:mapper/*.xml
#mybatis.type-aliases-package=com.beiluo.demo.entity
#开启驼峰命名 处理下划线映射到实体
mybatis.configuration.map-underscore-to-camel-case=true
查询后有数据
[{"id":1,"userName":"张三","phone":"13126789145","province":"03","userAccount":"zhangsan","userPassword":"zhangsan"}]