【发布时间】:2020-10-30 07:41:55
【问题描述】:
在我的 Spring Boot/Kotlin 项目中,我试图让 JSON 转换器忽略我的休息控制器响应中的空值。
我尝试在 application.yml 中设置以下内容:
spring:
jackson:
default-property-inclusion: non_null
我还尝试提供Jackson2ObjectMapperBuilder 和@ObjectMapper 类型的@Bean 配置为.serializationInclusion(JsonInclude.Include.NON_NULL),但它仍在序列化所有空属性。
使用 Spring Boot 2.3.0、Kotlin 1.3.72、AdoptOpenJDK 13
【问题讨论】:
标签: spring-boot kotlin jackson spring-autoconfiguration