我遇到了 MongoDB 的问题。我使用 sudo apt-get install mongodb 在我的 linux 服务器上安装了它。当我现在尝试将我的 java 驱动程序连接到它时,它说
Caused by: com.mongodb.MongoIncompatibleDriverException: This version of the driver is not compatible with one or more of the servers to which it is connected: ClusterDescription{type=STANDALONE, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=127.0.0.1:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[2, 4, 10]}, minWireVersion=0, maxWireVersion=0, maxDocumentSize=16777216, roundTripTimeNanos=708358}]}
我在服务器上的 mongodb 版本似乎比我的驱动程序版本旧。 我的java驱动版本是3.6 mongo-version 显示 2.4
我该如何解决这个问题?
最佳答案
如果您使用 Docker 来包装您的数据库,我建议将您的 ubuntu 版本更改为 16.04LTS,然后您的 mongod 将默认安装 2.6.10。
用java Driver运行就够了,不用弄3.x了。
这是 Dockerfile :
FROM ubuntu:16.04
RUN apt-get update && apt-get install -yq mongodb && apt-get clean && rm -rf /var/lib/apt/lists/*
ENTRYPOINT mongod --dbpath /data/db --rest
关于java - MongoDB Java 驱动错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48544194/