Can't find MongoClient in Java Drivers

元气小坏坏 提交于 2019-12-22 01:39:17

问题


In reading all the documentation on the mongo site for using the Java Driver, it makes references to using MongoClient() to make a connection. It talks about how they formerly used Mongo() but it has been deprecated. However, when I download the latest (or any) version of the java driver that the Mongo database links to (http://central.maven.org/maven2/org/mongodb/mongo-java-driver/), and load it into my project libraries, I cannot import com.mongodb.MongoClient because it isn't there! I've tried half a dozen different versions of the driver they link to. I can actually make my program work just fine with the deprecated Mongo(), but I don't want to be building new software on deprecated features. I can't find anyone else with the same problem on here either

The above is from version 2.93. Can anyone help me find what I'm doing wrong or missing? I would think its the driver version but these are the links right from Mongo's website. I also don't think its usage error, as I can make everything else work just fine.


回答1:


I suggest you grab driver version 2.11.3

The JAR contains the MongoClient class that you're referring to. Latter is new to the MongoDB Java driver and has only been included since version 2.10.0 (The version you are referring to is 2.9.3, as of now the latest driver version is the aforementioned 2.11.3)

Cheers ;)



来源:https://stackoverflow.com/questions/16497799/cant-find-mongoclient-in-java-drivers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!