今天拉取一个git代码,启动后报错:java.lang.NoClassDefFoundError: lombok/Data
检查以后,发现是因为属性上使用了Data,引用的是lombok.Data的包造成的。
可以看到这个类中有一个好几个Data。这里就很严重了,造成这个问题的原因是把Date写成了Data了。所以会报错lombok/Data问题。
要全局检查这样属性写成Data,然后引用的是lombok.Data的包,这种地方。
package com.ly.frauddataplatform.model.qo;import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;/*** @Description: 用户画像-模板列表请求参数类* @Version: V1.0*/
@ApiModel
@Data
public class RcPortraitTemplateQO extends PageQO{@ApiModelProperty(name = "id", value = "主键", example = "1")private Long id;/*** 模板名称**/@ApiModelProperty(name = "templateName",value = "模板名称",example = "xxx模板")private String templateName;/*** 模板内容**/@ApiModelProperty(name = "templateContent",value = "模板内容",example = "xxxjson字符串")private String templateContent;/*** 备注**/@ApiModelProperty(name = "remark",value = "备注",example = "适用于那个项目")private String remark;/*** 创建时间**/@ApiModelProperty(name = "createTime",value = "创建时间",example = "2024-02-23 00:00:00")@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")private Data createTime;/*** 修改时间**/@ApiModelProperty(name = "updateTime",value = "修改时间",example = "2024-02-23 00:00:00")@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")private Data updateTime;/*** 操作人**/@ApiModelProperty(name = "operator",value = "操作人",example = "罗焱-1211535")private String operator;
}
错误的代码,可以看到这里引用的是lombok的包。类的属性类型却也使用了Data,应该使用的是Date
package com.ly.frauddataplatform.model.qo;import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;/*** 创建时间**/@ApiModelProperty(name = "createTime",value = "创建时间",example = "2024-02-23 00:00:00")@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")private Data createTime;/*** 修改时间**/@ApiModelProperty(name = "updateTime",value = "修改时间",example = "2024-02-23 00:00:00")@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")private Data updateTime;
正确的代码:修改以后:
package com.ly.frauddataplatform.model.qo;import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;import java.util.Date;/*** 创建时间**/@ApiModelProperty(name = "createTime",value = "创建时间",example = "2024-02-23 00:00:00")@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")private Date createTime;/*** 修改时间**/@ApiModelProperty(name = "updateTime",value = "修改时间",example = "2024-02-23 00:00:00")@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")private Date updateTime;