我想在 mongo db 上设置一个更改流,但是有一个“无法解决重载方法订阅”,我无法找到问题的根源:
import org.mongodb.scala.{Document, MongoClient, MongoCollection, MongoDatabase}
object App {
def main(args: Array[String]): Unit = {
val mongoClient: MongoClient = MongoClient("mongodb://localhost")
val database: MongoDatabase = mongoClient.getDatabase("db")
val collection: MongoCollection[Document] = database.getCollection("col")
collection.watch().subscribe(
(doc: Document) => println(doc.toJson),
(t: Throwable) => println(""),
() => println()
)
}
}
libraryDependencies += "org.mongodb.scala" %% "mongo-scala-driver" % "2.7.0"