Spring和MongoDB异步Java驱动程序-clusterListener不能为null

时间:2018-10-12 18:59:32

标签: java spring mongodb

我正在尝试使用MongoDB的异步Java驱动程序连接到MongoDB。

MongoClient mongoClient = MongoClients.create();

但是,它引发以下错误:

java.lang.IllegalArgumentException: clusterListener can not be null
    at com.mongodb.assertions.Assertions.notNull(Assertions.java:37)
    at com.mongodb.connection.ClusterSettings$Builder.addClusterListener(ClusterSettings.java:218)
    at com.mongodb.connection.DefaultClusterFactory.getClusterSettings(DefaultClusterFactory.java:190)
    at com.mongodb.connection.DefaultClusterFactory.create(DefaultClusterFactory.java:46)
    at com.mongodb.async.client.MongoClients.createCluster(MongoClients.java:96)
    at com.mongodb.async.client.MongoClients.create(MongoClients.java:55)
    at com.mongodb.async.client.MongoClients.create(MongoClients.java:75)
    at com.mongodb.async.client.MongoClients.create(MongoClients.java:45)
    at com.monbodb.async.mongoasync.MongoasyncApplication.main(MongoasyncApplication.java:22)

有人以前遇到过这种情况并有解决方案吗?

1 个答案:

答案 0 :(得分:0)

只需更新到mongo驱动程序版本(最新),并使用最新的依赖项重建项目。

我已经通过重建解决了这个问题。