使用Lombok时,数据库查不到值时,返回的JSON中为null的属性都不显示了,找了好久才找到解决方法:
在实体类上加:
@JsonInclude(value= JsonInclude.Include.ALWAYS)
例如:
@Data
@ApiModel(description = "Demo")
@JsonInclude(value= JsonInclude.Include.ALWAYS)
public class Demo{
@ApiModelProperty(value = "主键")
private Integer id;
@ApiModelProperty(value = "消息发布类型")
private String messageType;
}