Ganu
Ganu

Reputation: 559

How to set read preference from java driver in Mongodb

I want to set read preference to my 3-member replica set. How to configure it using spring.data.mongodb.uri from java driver. I want to set "secondary preferred" read preference.

Upvotes: 2

Views: 3033

Answers (1)

Sriram
Sriram

Reputation: 146

I haven't used Spring Data much, but you can set replica set location and read preferences using MongoDB's Connection String:

mongodb://example1.com,example2.com,example3.com/?readPreference=secondary

This link explains more about the MongoDB Connection String.

Upvotes: 2

Related Questions