Reputation: 6611
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
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