作者:手机用户2602881417 | 来源:互联网 | 2023-10-11 14:05
1.如果要dto上不显示null值的直段那么使用注解@Data@JsonInclude(JsonInclude.Include.NON_NULL)publicclassOrd
1. 如果要dto 上不显示 null 值的直段那么使用注解
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class OrderDTO {
//todo
}
2. 配置全局的设置可以在yml 配置文件
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password:
url: jdbc:mysql://localhost:3306/sell?serverTimezOne=GMT%2B8&characterEncoding=utf-8&userSSL=false
jpa:
show-sql: true
jackson:
default-property-inclusion: non_null
3.要字段必须返回
public class OrderDTO {
private String orderId;
private String buyerName;
private String buyerPhOne= "";
}