[JAVA-1689] Why not provide a constructor with a String-Multi hosts? Created: 16/Mar/15 Updated: 11/Sep/19 Resolved: 17/Mar/15 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | yangyameng | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Now, I put mongo.host1,mongo.host2,mongo.host3 ... in my db.properties file,and config the MongoClient bean in beans.xml of Spring, like this: Thanks~ |
| Comments |
| Comment by yangyameng [ 18/Mar/15 ] |
|
Thank u very very very much~~ and apologize for my unknowing... |
| Comment by Ross Lawley [ 17/Mar/15 ] |
|
Hi yyam, Thanks for the ticket, currently the preferred way for multiple hosts is either to use a MongoClientURI which is fully parsed or alternatively you can provide a list of ServerAddress to create the MongoClient instance. Depending on your needs you should be able to parse a single list either by using a MongoClientURI or by building a list of ServerAddresses. Either way should be achievable by only setting the hosts in a single place but it might depend on how your application is configured and which libraries you are using. For future, the best place for questions regarding MongoDB usage or the Java driver specifics is the mongodb-user mailinglist or stackoverflow as you will reach a boarder audience there, who may have already have a solution for this issue. Regards, Ross |