我正在尝试使用Mongodb和Morphia将数据放入datastore
并且它给了我一个错误:
Exception in thread "main" 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:117)
at com.mongodb.Mongo.createCluster(Mongo.java:744)
at com.mongodb.Mongo.createCluster(Mongo.java:728)
at com.mongodb.Mongo.<init>(Mongo.java:293)
at com.mongodb.Mongo.<init>(Mongo.java:288)
at com.mongodb.Mongo.<init>(Mongo.java:284)
at com.mongodb.MongoClient.<init>(MongoClient.java:179)
at com.mongodb.MongoClient.<init>(MongoClient.java:156)
at com.mongodb.MongoClient.<init>(MongoClient.java:146)
at me.oao.kaike.App.<init>(App.kt:59)
at me.oao.kaike.oaolauncher$main$1.invoke(oaolauncher.kt:17)
at me.oao.kaike.oaolauncher$main$1.invoke(oaolauncher.kt:11)
at org.jooby.JoobyKt$sam$Supplier$9b5c0843.get(Jooby.kt)
at org.jooby.Jooby.run(Jooby.java:2094)
at org.jooby.JoobyKt.run(Jooby.kt:327)
at me.oao.kaike.oaolauncher.main(oaolauncher.kt:17)
整个代码
companion object {
lateinit var client: MongoClient
lateinit var morphia: Morphia
lateinit var datastore: Datastore
}
init {
client = MongoClient("localhost", 27017)
morphia = Morphia()
datastore = morphia.createDatastore(client, "teste")
}
我不知道如何解决这个问题,有人可以帮忙吗?