我正在开发一个 Play 2.2 应用程序,自从我尝试添加我的 DB 层以来,事情对我来说有点南下。
以下是我的build.sbt
依赖项。如您所见,我使用mysql-connector-java
and play-slick
:
libraryDependencies ++= Seq(
jdbc,
anorm,
cache,
"joda-time" % "joda-time" % "2.3",
"mysql" % "mysql-connector-java" % "5.1.26",
"com.typesafe.play" %% "play-slick" % "0.5.0.8",
"com.aetrion.flickr" % "flickrapi" % "1.1"
)
我的application.conf
里面有一些类似的简单数据库内容:
db.default.url="jdbc:mysql://localhost/myDb"
db.default.driver="com.mysql.jdbc.Driver"
db.default.user="root"
db.default.pass=""
这是我的 Play 服务器启动时的样子:
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Ctrl+D to stop and go back to the console...)
[info] Compiling 1 Scala source to C:\bbq\cats\in\space
[info] play - database [default] connected at jdbc:mysql://localhost/myDb
[info] play - Application started (Dev)
因此,Play 似乎可以很好地连接到 MySQL DB(我认为)。但是,当我向我的服务器发出任何请求时,我得到了这个异常:
[error] p.nettyException - Exception caught in Netty
java.lang.NoSuchMethodError: akka.actor.ActorSystem.dispatcher()Lscala/concurren
t/ExecutionContext;
at play.core.Invoker$.<init>(Invoker.scala:24) ~[play_2.10.jar:2.2.0]
at play.core.Invoker$.<clinit>(Invoker.scala) ~[play_2.10.jar:2.2.0]
at play.api.libs.concurrent.Execution$Implicits$.defaultContext$lzycompu
te(Execution.scala:7) ~[play_2.10.jar:2.2.0]
at play.api.libs.concurrent.Execution$Implicits$.defaultContext(Executio
n.scala:6) ~[play_2.10.jar:2.2.0]
at play.api.libs.concurrent.Execution$.<init>(Execution.scala:10) ~[play
_2.10.jar:2.2.0]
at play.api.libs.concurrent.Execution$.<clinit>(Execution.scala) ~[play_
2.10.jar:2.2.0]
奇怪的是,第二个请求(到完全相同的 URL,相同的控制器,没有更改)返回一个不同的错误:
[error] p.nettyException - Exception caught in Netty
java.lang.NoClassDefFoundError: Could not initialize class play.api.libs.concurr
ent.Execution$
at play.core.server.netty.PlayDefaultUpstreamHandler.handleAction$1(Play
DefaultUpstreamHandler.scala:194) ~[play_2.10.jar:2.2.0]
at play.core.server.netty.PlayDefaultUpstreamHandler.messageReceived(Pla
yDefaultUpstreamHandler.scala:169) ~[play_2.10.jar:2.2.0]
at com.typesafe.netty.http.pipelining.HttpPipeliningHandler.messageRecei
ved(HttpPipeliningHandler.java:62) ~[netty-http-pipelining.jar:na]
at org.jboss.netty.handler.codec.http.HttpContentDecoder.messageReceived
(HttpContentDecoder.java:108) ~[netty-3.6.5.Final.jar:na]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:29
6) ~[netty-3.6.5.Final.jar:na]
at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessage
Received(FrameDecoder.java:459) ~[netty-3.6.5.Final.jar:na]
我请求的 URL / 控制器只是呈现一个静态网页,并没有做任何有意义的事情。在我开始添加我的数据库层之前它工作得很好。我比较卡。任何帮助将不胜感激,谢谢。
我正在使用 Scala 2.10.2、Play 2.2.0 和 MySQL Server 5.6.14.0(社区版)。