Spring data mongodb reactive: use spring.data.mongodb.uri or implement AbstractReactiveMongoConfiguration.getDatabaseName

Viewed 171

I'm reading on several sites, I need to configure something like that in order to get access to mongodb.

@EnableReactiveMongoRepositories
public class MongoReactiveApplication
  extends AbstractReactiveMongoConfiguration {

    @Override
    protected String getDatabaseName() {
        return "<database>";
    }
}

I'm using:

spring:
  data:
    mongodb:
      uri: mongodb://<user>:<password>@<rs1>:<port>,<rs2>:<port>,<rs3>:<port>/<database>

As you can see, I'm using spring.data.mongodb.uri property in order to set uri. Inside this value there is the <database>.

Why should I need to implement AbstractReactiveMongoConfiguration.getDatabaseName once again programatically?

0 Answers
Related