Spring Boot API :如果请求正文中的任何字段为空,它将在数据库中存储为 null

Spring Boot API : If any field is empty in request body it is storing as null in DB

如果请求正文中的任何字段为空,它在数据库中存储为 null,我猜这是因为实体 class。 例如:如果在实体 class 中有一个字段 "name"。 我的问题是,如果我没有在请求正文中传递 "name" 属性,它不应该在数据库中存储 null。怎么可能?

在实体级别或属性级别添加 @JsonInclude(Include.NON_NULL) Jackson 注释 以忽略空值或空值序列化 json.