我最近升级了Play到2.3.5版本并尝试与ReactiveMongo一起使用。然而,每次我尝试从mongoDB读取数据时都会出现异常。这是我的build.sbt文件:
name := """ReactiveMongoRestExample"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.1"
libraryDependencies ++= Seq(
jdbc,
anorm,
cache,
ws,
"org.reactivemongo" %% "play2-reactivemongo" % "0.10.5.0.akka23"
)
以下是堆栈跟踪信息:
play.api.Application$$anon$1: 执行异常[[PrimaryUnavailableException$: MongoError['No primary node is available!']]] at play.api.Application$class.handleError(Application.scala:296) ~[play_2.11-2.3.5.jar:2.3.5] at play.api.DefaultApplication.handleError(Application.scala:402) [play_2.11-2.3.5.jar:2.3.5] at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:205) [play_2.11-2.3.5.jar:2.3.5] at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:202) [play_2.11-2.3.5.jar:2.3.5] at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36) [scala-library-2.11.2.jar:na] Caused by: reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$: MongoError['No primary node is available!'] at reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$.(actors.scala) ~[reactivemongo_2.11-0.10.5.0.akka23.jar:0.10.5.0.akka23] at reactivemongo.core.actors.MongoDBSystem$$anonfun$pickChannel$4.apply(actors.scala:508) ~[reactivemongo_2.11-0.10.5.0.akka23.jar:0.10.5.0.akka23] at reactivemongo.core.actors.MongoDBSystem$$anonfun$pickChannel$4.apply(actors.scala:508) ~[reactivemongo_2.11-0.10.5.0.akka23.jar:0.10.5.0.akka23] at scala.Option.getOrElse(Option.scala:120) ~[scala-library-2.11.2.jar:na] at reactivemongo.core.actors.MongoDBSystem.pickChannel(actors.scala:508) ~[reactivemongo_2.11-0.10.5.0.akka23.jar:0.10.5.0.akka23]
MongoDB正常工作。我能够使用命令行工具和IntelliJ检索数据。
我将代码推送到github
也许有人知道问题并可以帮助我?那将非常棒。