问题:Spring Data 未能创建 MongoDB TTL 索引
我有一个使用 Spring Boot 的应用程序,使用 MongoDB 作为数据库。
我有一个实体类:
我使用这个仓库将一个新的文档持久化到MongoDB中:
使用
但是在插入Person文档后,MongoDB上没有创建TTL索引: 截图 请指导我做错了什么。
我有一个使用 Spring Boot 的应用程序,使用 MongoDB 作为数据库。
我有一个实体类:
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Document(COLLECTION_NAME)
public class PersonEntity {
public static final String COLLECTION_NAME = "person_info";
private static final String PERSON_NAME = "person_name";
@Id
private PersonId id;
@Field(name = PERSON_NAME)
private String personName;
@Indexed(name = "ttl_index", expireAfterSeconds=20)
private LocalDateTime date;
}
我使用这个仓库将一个新的文档持久化到MongoDB中:
public interface SellerRequestInfoRepository extends ReactiveMongoRepository<PersonEntityEntity, PersonId> {}
使用
personRepository.save(entity);
但是在插入Person文档后,MongoDB上没有创建TTL索引: 截图 请指导我做错了什么。