@Bean
    public MongoClient mongoClient() {
        MongoClientOptions.Builder options = MongoClientOptions.builder()   //TODO: make connection options configurable
                .connectionsPerHost(4)
                .maxConnectionIdleTime(60000)
                .maxConnectionLifeTime(120000);
        ServerAddress serverAddress = new ServerAddress(mongoConfiguration.getHost(), mongoConfiguration.getPort());
        MongoCredential credential = getCredentials(mongoConfiguration.getAuth());
        if (credential == null) {
            LOG.info("Connecting to mongo without auth");
        } else {
            LOG.info("Mongo credential: user: '{}', password: '***', authenticationDatabase: '{}'", mongoConfiguration.getAuth().getUser(), mongoConfiguration.getAuth().getAuthBase());
        }
        return credential == null ? new MongoClient(serverAddress) :
                new MongoClient(serverAddress, Collections.singletonList(credential), options.build());
    }
@Bean
    public MongoClient mongoClient() {
        MongoClientOptions.Builder options = MongoClientOptions.builder()  
                .connectionsPerHost(4)
                .maxConnectionIdleTime(60000)
                .maxConnectionLifeTime(120000);
        ServerAddress serverAddress = new ServerAddress(mongoConfiguration.getHost(), mongoConfiguration.getPort());
        MongoCredential credential = getCredentials(mongoConfiguration.getAuth());
        if (credential == null) {
            LOG.info("Connecting to mongo without auth");
        } else {
            LOG.info("Mongo credential: user: '{}', password: '***', authenticationDatabase: '{}'", mongoConfiguration.getAuth().getUser(), mongoConfiguration.getAuth().getAuthBase());
        }
        return credential == null ? new MongoClient(serverAddress) :
                new MongoClient(serverAddress, Collections.singletonList(credential), options.build());
    }
@bean public mongoclient mongoclient() { mongoclientoptions.builder options = mongoclientoptions.builder() .connectionsperhost(4) .maxconnectionidletime(60000) .maxconnectionlifetime(120000); serveraddress serveraddress = new serveraddress(mongoconfiguration.gethost(), mongoconfiguration.getport()); mongocredential credential = getcredentials(mongoconfiguration.getauth()); if (credential == null) { log.info("connecting to mongo without auth"); } else { log.info("mongo credential: user: '{}', password: '***', authenticationdatabase: '{}'", mongoconfiguration.getauth().getuser(), mongoconfiguration.getauth().getauthbase()); } return credential == null ? new mongoclient(serveraddress) : new mongoclient(serveraddress, collections.singletonlist(credential), options.build()); }