Spring 数据 Mongo @CreatedAt 注释不适用于嵌套文档字段

Spring Data Mongo @CreatedAt annotation not working with nested document field

我正在使用 Spring Boot 2.4.0 以及 Spring 数据 Mongo。

映射到集合的 POJO class 是:

@SuppressFBWarnings(value = {"EI_EXPOSE_REP", "EI_EXPOSE_REP2"},
  justification = "This is a bean")
@Document(collection = "Posts")
@Data
@Builder
public class Post {

@Id
private String id;
private ActorInfo actorInfo;
private String text;
private Media media;
private int likes; 
private Meta meta;
@Version
private Integer version;

@Data
@Builder
public static class Meta {
   @CreatedDate // <-- this is not working
   private Instant createdAt;
   @LastModifiedDate // <-- this is not working
   private Instant updatedAt;
   private String event; 
}

}

我正在使用 MongoRepository 使用 save() 将 POJO 保存在数据库中。 但是我没有看到集合中填充了 createdAt 和 updatedAt。
这是保存在集合中的内容:

{ "_id" : ObjectId("600fc6b23d5ebf145b7bbc0d"), "actorInfo" : { "_id" : "1", "role" : "USER" }, "text" : "Helo", "likes" : 0, "meta" : { "event" : "CREATED" }, "version" : 0, "_class" : "com.highstreet.socialmediaservice.adpater.output.type.Post" }

你启用审计了吗? https://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#mongo.auditing