MybatisPlus 解决 org.apache.ibatis.reflection.ReflectionException: Could not set property ‘id‘ of 问题
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="EduSubject对象", description="课程科目")
public class EduSubject implements Serializable {
private static final long serialVersionUID=1L;
@ApiModelProperty(value = "课程类别ID")
//重点,记得修改type = IdType.ID_WORKER_STR
@TableId(value = "id", type = IdType.ID_WORKER_STR)
private String id;
@ApiModelProperty(value = "类别名称")
private String title;
@ApiModelProperty(value = "父ID")
private String parentId;
@ApiModelProperty(value = "排序字段")
private Integer sort;
@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
private Date gmtCreate;
@ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date gmtModified;
}
@TableId(value = “id”, type = IdType.ID_WORKER_STR) 这个很重要,如果你的数据库id是int类型,可以省略,如果数据库id是使用的String类型,必须加上type = IdType.ID_WORKER_STR。
至此,问题解决