spring boot过滤null值
1.全局,若是以下格式,注意jackson的缩进!
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: 123456
url: jdbc:mysql://192.168.1.121/shopping?characterEncoding=utf-8&useSSL=false
jpa:
show-sql: true
jackson:
default-property-inclusion: non_null
2.局部,在需要的类前面添加以下标红的注解
@JsonInclude(JsonInclude.Include.NON_NULL) public class OrderTransport { private String name; private Integer age; }