Skip to content

Autoconfigure ReactiveGridFsTemplate with MongoProperties.getGridFsDatabase() #18284

@m-prati

Description

@m-prati

Using ReactiveGridFsTemplate I noticed that it is always user the main database, even if GridFsDatabase is specified.
I've adopted the workaround of defining my Bean

@Bean
public ReactiveMongoDatabaseFactory reactiveMongoDatabaseFactory(
   MongoProperties properties, MongoClient mongo) {
       String database = StringUtils.firstNonBlank(
         properties.getGridFsDatabase(), 
         properties.getMongoClientDatabase());
    return new SimpleReactiveMongoDatabaseFactory(mongo, database);
}

And I think this can be a useful solution for standard autoconfigure of ReactiveGridFsTemplate in
org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration file

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions