我有以下代码在引用时可在控制台应用程序中使用 "org.reactivemongo" %% "play2-reactivemongo" % "0.10.5.0.akka23"
"org.reactivemongo" %% "play2-reactivemongo" % "0.10.5.0.akka23"
当我更新对我的引用时,"org.reactivemongo" % "play2-reactivemongo_2.11" % "0.11.0.play23-M3"得到:
"org.reactivemongo" % "play2-reactivemongo_2.11" % "0.11.0.play23-M3"
找不到play.api.libs.json.JsObject类型的Json序列化程序作为JsObject。尝试为此类型实现隐式OWrites或OFormat。
import org.joda.time.DateTime import reactivemongo.bson.BSONObjectID import play.modules.reactivemongo.json.BSONFormats._ case class GoogleToken ( id: Option[BSONObjectID], name: String, emailAddress: String, refreshToken: String, expires: DateTime ) object GoogleToken { import play.api.libs.json.Json // Generates Writes and Reads implicit val googleTokenFormat = Json.format[GoogleToken] }
然后
val collection = db.collectionJSONCollection
val query = Json.obj() val cursor = collection.find(query). cursor[GoogleToken](ReadPreference.nearest). collect[List]()
我究竟做错了什么?
ReactiveMongo 0.11的最终版本已发布("org.reactivemongo" %% "play2-reactivemongo" % "0.11.0.play23")。
"org.reactivemongo" %% "play2-reactivemongo" % "0.11.0.play23"
如更新的文档中所述,对于默认的BSON / JSON转换,建议具有:import play.modules.reactivemongo.json._, ImplicitBSONHandlers._。
import play.modules.reactivemongo.json._, ImplicitBSONHandlers._