#553 - Upgrade Mongo/Rest examples to Spring Boot 2.3.

This commit is contained in:
Mark Paluch
2020-05-11 14:23:49 +02:00
parent f64280153d
commit 475ecccab1

View File

@@ -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);