Using the Mongobee for Migration with spring mongo
plugins {
id \'org.springframework.boot\' version \'2.3.1.RELEASE\'
id \'io.spring.dependency-manageme
It seems you don't have the bean created for "MongoTemplate"
Create a bean for it and use that to setMongoTemplate for Mongobee.
Below is the example to do so
@Bean
public MongoClient mongo() {
return new MongoClient("localhost");
}
@Bean
public MongoTemplate mongoTemplate() throws Exception {
return new MongoTemplate(mongo(), "test");
}
then use this
@Bean
public Mongobee mongobee(){
logger.info("Starting product migration ...");
String mongoUri = environment.getProperty("spring.data.mongodb.uri");
boolean migrationsEnabled = Boolean.parseBoolean(environment.getProperty("app.db.migrations.enabled"));
Mongobee runner = new Mongobee(mongoUri);
runner.setEnabled(migrationsEnabled);
runner.setChangeLogsScanPackage("fete.bird.fetebirdproduct.migration");
runner.setChangelogCollectionName("migrations");
runner.setLockCollectionName("migrations_lock");
runner.setMongoTemplate(mongoTemplate());
logger.info("Product migration completed...");
return runner;
}
Now, you don't have to use constructor dependency and later wherever you want MongoTemplate you can use
@Autowired
MongoTemplate mongoTemplate;
Hope, this will solve your problem !!