1.在相应的属性上加注解
@JsonInclude(JsonInclude.Include.NON_NULL)
2.在SpringBoot的yml配置文件中加全局配置
spring:
jackson:
default-property-inclusion: non_null
3.设置ObjectMapper,做成统一的配置处理Jackson2ObjectMapperBuilderCustomizer
1.在相应的属性上加注解
@JsonInclude(JsonInclude.Include.NON_NULL)
2.在SpringBoot的yml配置文件中加全局配置
spring:
jackson:
default-property-inclusion: non_null
3.设置ObjectMapper,做成统一的配置处理Jackson2ObjectMapperBuilderCustomizer