Ik heb dit probleem opgelost met de volgende configuratie:
@Configuration
@EnableMongoRepositories(basePackages = "YOUR.PACKAGE")
@EnableMongoAuditing
public class MongoConfig extends AbstractMongoConfiguration {
@Value("${spring.data.mongodb.host}")
private String host;
@Value("${spring.data.mongodb.port}")
private Integer port;
@Value("${spring.data.mongodb.database}")
private String database;
@Override
public MongoClient mongoClient() {
return new MongoClient(host, port);
}
@Override
protected String getDatabaseName() {
return database;
}
@Bean
public MongoTemplate mongoTemplate() throws Exception {
return new MongoTemplate(mongoDbFactory(), mappingMongoConverter());
}
@Bean
public MongoDbFactory mongoDbFactory() {
return new SimpleMongoDbFactory(mongoClient(), database);
}
}
voeg gewoon de boon toe voor MongoTemplate
met de constructor van MongoTemplate(MongoDbFactory mongoDbFactory, @Nullable MongoConverter mongoConverter)