1

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?.

1 Answer 1

1

You can use 'com.mongodb.MongoClientOptions'

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

ServerAddress severAddress = new ServerAddress( mongoDbAddress );

return new MongoClient( severAddress, options );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.