mybatis plus 报错:Error getting generated key or setting result to parameter object. Cause: org.apache.ibatis.excutor.ExcutorException: No setter found for the keyProperty ‘id’ in java.lang.Class.
代码如下:
@Data
public class Model{
@TableId(type = IdType.AUTO)
private Long id;
...
}
后发现是因为@TableId没有指定value导致无法映射到对应的id字段上。
解决方法: 加上value即可。
@TableId(value = "id", type = IdType.AUTO)