如何忽略 Spring 数据 Mongo 的 @Indexed 注释
How to ignore @Indexed annotation for Spring Data Mongo
我有多个项目使用相同的 class 用户,该用户具有以下注释:
@Indexed(direction=IndexDirection.DESCENDING)
private Date created = null;
我不希望每个项目都生成对 mongo 的调用来创建索引,因为这会导致问题(例如,如果我想更改索引)。
有没有办法通过配置文件(或其他方式)让Spring数据Mongo忽略@Indexed注解?
即将推出的 Spring 数据 MongoDB 2.2 允许通过 MongoConfigurationSupport#autoIndexCreation
或直接调用 mongoMappingContext.setAutoIndexCreation(false)
.
关闭带注释的索引创建
我有多个项目使用相同的 class 用户,该用户具有以下注释:
@Indexed(direction=IndexDirection.DESCENDING)
private Date created = null;
我不希望每个项目都生成对 mongo 的调用来创建索引,因为这会导致问题(例如,如果我想更改索引)。
有没有办法通过配置文件(或其他方式)让Spring数据Mongo忽略@Indexed注解?
即将推出的 Spring 数据 MongoDB 2.2 允许通过 MongoConfigurationSupport#autoIndexCreation
或直接调用 mongoMappingContext.setAutoIndexCreation(false)
.