Harmeet Singh Taara
Harmeet Singh Taara

Reputation: 6611

Spring-Data: Define <mongo:options> using java based config

When we configure Spring-Data for mongo-db we have options for configure using Java based and XML based. In XML based configurations, we also customize mango options using <mongo:options connections-per-host="4" ... tag, But in java based configuration, how i set these options for Mongo Configuration?.

Upvotes: 1

Views: 575

Answers (1)

anztenney
anztenney

Reputation: 686

You can use 'com.mongodb.MongoClientOptions'

MongoClientOptions options = MongoClientOptions.builder()
                                 .connectionsPerHost( 4 ).build();

ServerAddress severAddress = new ServerAddress( mongoDbAddress );

return new MongoClient( severAddress, options );

Upvotes: 1

Related Questions