#553 - Upgrade Mongo/Rest examples to Spring Boot 2.3.
This commit is contained in:
@@ -32,6 +32,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.index.IndexDefinition;
|
||||
import org.springframework.data.mongodb.core.index.IndexResolver;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@@ -51,6 +53,12 @@ public class StoreInitializer {
|
||||
return;
|
||||
}
|
||||
|
||||
Iterable<? extends IndexDefinition> indexDefinitions = IndexResolver
|
||||
.create(operations.getConverter().getMappingContext())
|
||||
.resolveIndexFor(Store.class);
|
||||
|
||||
indexDefinitions.forEach(operations.indexOps(Store.class)::ensureIndex);
|
||||
|
||||
List<Store> stores = readStores();
|
||||
log.info("Importing {} stores into MongoDB…", stores.size());
|
||||
repository.saveAll(stores);
|
||||
|
||||
Reference in New Issue
Block a user