use of org.springframework.data.document.mongodb.SimpleMongoDbFactory in project spring-data-document-examples by spring-projects.
the class MongoConfiguration method mongoTemplate.
@Bean
public MongoOperations mongoTemplate() throws Exception {
Mongo m = new Mongo();
MongoOperations operations = new MongoTemplate(new SimpleMongoDbFactory(m, "mvc"));
if (!operations.collectionExists("mvc")) {
operations.createCollection("mvc");
}
if (!operations.collectionExists("counters")) {
operations.createCollection("counters");
}
return operations;
}
Aggregations