我一直在尝试让SORM使用Play Framework 2.2-SNAPSHOT以及2.1.1。目前,我正在尝试运行我创建的简约示例应用程序,以便更轻松地跟踪问题。不幸的是,我收到的错误消息对我没有任何帮助。
val appDependencies = Seq(
"org.sorm-framework" % "sorm" % "0.3.8",
"com.h2database" % "h2" % "1.3.168"
)
# Database configuration
#
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play"
# db.default.user=sa
# db.default.password=""
case class Car( brand: String, wheels: Int )
object Db extends Instance( Seq( Entity[Car]() ), "jdbc:h2:mem:play" )
object Application extends Controller {
def index = Action {
Db.query[Car].count()
Ok("hello wolrd")
}
}
此堆栈跟踪中的结果:
play.api.Application$$anon$1: Execution exception[[RuntimeException: java.lang.NoSuchMethodError: scala.reflect.internal.TreeInfo.firstArgument(Lscala/reflect/internal/Trees$Tree;)Lscala/reflect/internal/Trees$Tree;]]
at play.api.Application$class.handleError(Application.scala:289) ~[play_2.10.jar:2.1.1]
at play.api.DefaultApplication.handleError(Application.scala:383) [play_2.10.jar:2.1.1]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$17$$anonfun$apply$24.apply(PlayDefaultUpstreamHandler.scala:326) [play_2.10.jar:2.1.1]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$17$$anonfun$apply$24.apply(PlayDefaultUpstreamHandler.scala:324) [play_2.10.jar:2.1.1]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10.jar:2.1.1]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10.jar:2.1.1]
java.lang.RuntimeException: java.lang.NoSuchMethodError: scala.reflect.internal.TreeInfo.firstArgument(Lscala/reflect/internal/Trees$Tree;)Lscala/reflect/internal/Trees$Tree;
at play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:222) ~[play_2.10.jar:2.1.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:109) ~[play_2.10.jar:2.1.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:109) ~[play_2.10.jar:2.1.1]
at play.utils.Threads$.withContextClassLoader(Threads.scala:18) ~[play_2.10.jar:2.1.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:108) ~[play_2.10.jar:2.1.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:106) ~[play_2.10.jar:2.1.1]
Caused by: java.lang.NoSuchMethodError: scala.reflect.internal.TreeInfo.firstArgument(Lscala/reflect/internal/Trees$Tree;)Lscala/reflect/internal/Trees$Tree;
at scala.tools.nsc.typechecker.Typers$Typer.parentTypes(Typers.scala:1550) ~[scala-compiler.jar:na]
at scala.tools.nsc.typechecker.Namers$Namer.templateSig(Namers.scala:861) ~[scala-compiler.jar:na]
at scala.tools.nsc.typechecker.Namers$Namer.getSig$1(Namers.scala:1300) ~[scala-compiler.jar:na]
at scala.tools.nsc.typechecker.Namers$Namer.typeSig(Namers.scala:1347) ~[scala-compiler.jar:na]
at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$monoTypeCompleter$1$$anonfun$apply$1.apply$mcV$sp(Namers.scala:709) ~[scala-compiler.jar:na]
at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$monoTypeCompleter$1$$anonfun$apply$1.apply(Namers.scala:708) ~[scala-compiler.jar:na]
答案 0 :(得分:5)
好。这不是一个错误。 SORM 0.3.8 取决于 Scala 2.10.1 , Play 2.1.x 使用 Scala 2.10.0 。您获得的例外情况是由 Scala 版本的播放混合工件引起的。
要解决此问题,您需要做的就是通过将scalaVersion := "2.10.1"
添加到文件中的项目设置,告诉播放使用正确的 Scala 版本< EM>项目/ Build.scala
最终的构建脚本可能如下所示:
object ApplicationBuild extends Build {
val appName = "play-test"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
"org.sorm-framework" % "sorm" % "0.3.8",
"com.h2database" % "h2" % "1.3.168"
)
val main = play.Project(appName, appVersion, appDependencies).settings(
resolvers +=
"Local Maven Repository" at
"file:///"+Path.userHome.absolutePath+"/.m2/repository",
scalaVersion := "2.10.1" // <--- ! This is the fix !
)
}