我是scala和sbt的新手。经过大量调查后,我提出了以下build.sbt。我无法找到解决方案。对我来说非常有帮助。
scalaVersion := "2.11.7"
scalaVersion in ThisBuild := "2.11.7"
val sparkVersion = "1.3.0"
val akkaVersion = "2.3.6"
libraryDependencies ++= Seq(
jdbc,
cache,
"com.typesafe.play" % "play_2.11" % "2.5.0-M2",
"org.slf4j" % "jcl-over-slf4j" % "1.7.18",
"org.slf4j" % "slf4j-simple" % "1.6.2",
"com.typesafe.akka" % "akka-actor_2.11" % "2.4.2",
"com.typesafe.akka" % "akka-slf4j_2.11" % "2.4.2",
"org.webjars" % "webjars-play_2.11" % "2.4.0-2",
"com.typesafe.play" % "play-ws_2.11" % "2.5.0-M2",
"org.webjars" % "bootstrap" % "3.2.0",
"org.webjars" % "html5shiv" % "3.7.0",
"org.webjars" % "respond" % "1.4.2",
"com.twitter" %% "algebird-core" % "0.9.0", // Twitter Algebird
"net.databinder.dispatch" % "dispatch-core_2.11" % "0.11.3",
"org.reactivemongo" % "play2-reactivemongo_2.11" % "0.11.10.play23",
"org.specs2" %% "specs2-core" % "3.6.5" % "test",
"org.specs2" %% "specs2-junit" % "3.6.5" % "test",
"org.specs2" %% "specs2-mock" % "3.6.5" % "test",
"org.mongodb" %% "casbah" % "2.8.1", // MongoDB Casbah
"com.sksamuel.elastic4s" %% "elastic4s" % "1.4.14"
)
编译很好但是出现运行时错误,我不确定错误在哪里。
错误:
java.lang.NoSuchMethodError: play.api.Logger$.init(Ljava/io/File;Lscala/Enumeration$Value;)V
at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:88)
at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:61)
at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
at play.core.server.DevServerStart$.mainDev(DevServerStart.scala:60)
at play.core.server.DevServerStart$.mainDevHttpMode(DevServerStart.scala:50)
at play.core.server.DevServerStart.mainDevHttpMode(DevServerStart.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at play.runsupport.Reloader$.startDevMode(Reloader.scala:223)
at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.devModeServer$lzycompute$1(PlayRun.scala:74)
at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.play$sbt$run$PlayRun$$anonfun$$anonfun$$anonfun$$devModeServer$1(PlayRun.scala:74)
at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:100)
at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:53)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) java.lang.reflect.InvocationTargetException
[error] Total time: 1 s, completed 7 Mar, 2016 8:05:59 PM
答案 0 :(得分:7)
您无法混合搭配不同的Play版本。
ReactiveMongo "0.11.10.play23"
实际需要播放2.3。您尝试使用里程碑2 Play 2.5开发版本。
目前最新的官方Play版本为2.4.6,因此请勿使用Play 2.5的开发里程碑(M2),目前尚未最终确定。
Play 2.4的匹配ReactiveMongo版本。使用它。
此外,当你想开发一个Play应用程序时,你应该只使用(typesafe)lightbend" Activator"使用Play SBT插件生成一个合适的项目模板(具有适当的模板和路由编译支持等)。