我是 scala 和 casbah 的新手。我正在尝试使用 casbah 创建一个 mongo 副本集连接。这是我的代码。我很确定我的 mongo 副本设置是正确的。当我通过 ruby 创建连接时,效果很好。我在这里错过了一些愚蠢的东西。当我用谷歌搜索时,我得到了这个文档,这是我用来参考的。
http://api.mongodb.org/scala/casbah/current/scaladoc/com/mongodb/casbah/MongoConnection $.html
import com.mongodb.casbah.Imports._
object MongoAnalysisDB {
def main(args: Array[String]) = {
//that connection
val addresses = List("127.0.0.1:27018", "127.0.0.1:27019", "127.0.0.1:27020")
val mongoConn = MongoConnection(replicaSetSeeds: addresses)
val mongoDB = mongoConn("vimana-sandbox-dup")
val mongoColl = mongoConn("vimana-sandbox-dup")("utilization.metrics.cycledowntime")
//that query
val loadEvent = MongoDBObject("period" -> "PT1H")
val cursor = mongoColl.find(loadEvent)
val mtcevent = mongoColl.findOne(loadEvent)
//that document
println(mtcevent)
}
}
我收到以下错误。
[info] Compiling 1 Scala source to /home/deepak/scala-mongo-oplog-watcher/target/scala-2.9.1/classes...
[error] /home/deepak/scala-mongo-oplog-watcher/src/main/scala/reader.scala:6: ')' expected but '(' found.
[error] val mongoConn = MongoConnection(replicaSetSeeds: List("127.0.0.1:27018", "127.0.0.1:27019", "127.0.0.1:27020"))
[error] ^
[error] /home/deepak/scala-mongo-oplog-watcher/src/main/scala/reader.scala:6: ';' expected but ')' found.
[error] val mongoConn = MongoConnection(replicaSetSeeds: List("127.0.0.1:27018", "127.0.0.1:27019", "127.0.0.1:27020"))
[error] ^
[error] two errors found
[error] {file:/home/deepak/scala-mongo-oplog-watcher/}default-b16d47/compile:compile: Compilation failed