After upgrading to spring-boot 3 mongo auto configuration is not working, when connection string is used.
I think we need to have a fallback option if this.connectionDetails.getConnectionString().getDatabase() is null.
@Bean
@ConditionalOnMissingBean(ReactiveMongoDatabaseFactory.class)
public SimpleReactiveMongoDatabaseFactory reactiveMongoDatabaseFactory(MongoClient mongo) {
return new SimpleReactiveMongoDatabaseFactory(mongo,
this.connectionDetails.getConnectionString().getDatabase());
}
Can we change the above code as mentioned below?
@Bean
@ConditionalOnMissingBean(ReactiveMongoDatabaseFactory.class)
public SimpleReactiveMongoDatabaseFactory reactiveMongoDatabaseFactory(MongoProperties properties, MongoClient mongo) {
String database = this.connectionDetails.getConnectionString().getDatabase();
if(database==null)
database = properties.getDatabase()
return new SimpleReactiveMongoDatabaseFactory(mongo,
database);
}