mongo java client,在Java驱动程序中找不到MongoClient

博主在尝试使用MongoDB Java驱动器时遇到问题,文档提到应使用MongoClient进行连接,但下载的最新版本库中找不到这个类。尽管可以使用已弃用的Mongo()方法,但博主希望避免使用过时功能。问题出在下载的驱动版本不包含MongoClient,而该类从2.10.0版本开始引入。解决方案是确保使用至少2.10.0或更高版本的驱动。
摘要由CSDN通过智能技术生成

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

qEViI.png

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.

解决方案

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 ;)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值