#553 - Upgrade Mongo examples to Spring Boot 2.3.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package example.springdata.mongodb.textsearch;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -24,11 +25,13 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.index.IndexResolver;
|
||||
import org.springframework.data.repository.init.Jackson2RepositoryPopulatorFactoryBean;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Configuration
|
||||
@SpringBootApplication
|
||||
@@ -43,6 +46,14 @@ public class MongoTestConfiguration {
|
||||
return factoryBean;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
private void postConstruct() {
|
||||
|
||||
IndexResolver resolver = IndexResolver.create(operations.getConverter().getMappingContext());
|
||||
|
||||
resolver.resolveIndexFor(BlogPost.class).forEach(operations.indexOps(BlogPost.class)::ensureIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up after execution by dropping used test db instance.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user