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 = "";
}

 

相关文章:

  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2021-04-18
  • 2022-12-23
  • 2022-02-16
  • 2021-07-31
猜你喜欢
  • 2021-08-08
  • 2022-12-23
  • 2021-07-30
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
  • 2021-09-28
相关资源
相似解决方案