一、问题描述
在使用mybatis-plus时候,会在实体中添加一些数据库表中不存在的字段,为了在页面显示该属性,如果运行那么这个字段就会无法进行自动映射而报错。
二、报错如下Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column ‘***’ in ‘field list’
三、解决方式- 例如:age属性在表中不存在,在实体中添加age属性,需要在字段上加注解 @TableField(exist = false)
@Data
@TableName("sys_user")
public class UserEntity{
private String id;
private String user_name;
@TableField(exist = false)
private Integer user_age;
}