📜  mongodb spring boot index usage 0 - 不管代码示例

📅  最后修改于: 2022-03-11 14:55:41.047000             🧑  作者: Mango

代码示例3
MongoDatabaseFactory dbFactory = new SimpleMongoClientDatabaseFactory(...);
DefaultDbRefResolver dbRefResolver = new DefaultDbRefResolver(dbFactory);

MongoMappingContext mappingContext = new MongoMappingContext();
mappingContext.setAutoIndexCreation(true);                
// ...
mappingContext.afterPropertiesSet();

MongoTemplate template = new MongoTemplate(dbFactory, new MappingMongoConverter(dbRefResolver, mappingContext));