Lagom与MySQL Db连接

时间:2018-12-17 18:59:51

标签: mysql playframework akka lagom

我想将lagom连接到MySQL数据库,我下载了一个在Lagom站点中创建的项目。我在hello-impl pom中添加了以下依赖项,然后applicaiont.conf配置数据库详细信息。

<dependency>
        <groupId>com.lightbend.lagom</groupId>
        <artifactId>lagom-javadsl-persistence-jdbc_${scala.binary.version}</artifactId>
        <version>${lagom.version}</version>
</dependency>

aplication.conf

db.default {
  driver = "com.mysql.jdbc.Driver"
  url = "jdbc:mysql://localhost:3306/test"
  user = "root"
  password = ""
}
jdbc-defaults.slick.profile = "slick.jdbc.MySQLProfile$"
lagom.persistence.jdbc.create-tables.auto = true

在我运行应用程序之后,出现以下错误。有什么错 我是Lagom的新手,请详细说明。

{"name":"akka.pattern.AskTimeoutException: Ask timed out on [Actor[akka://hello-impl-application/system/sharding/HelloEntity#976224651]] after [10000 ms]. Message of type [com.lightbend.lagom.javadsl.persistence.CommandEnvelope]. A typical reason for `AskTimeoutException` is that the recipient actor didn't send a reply.","detail":"akka.pattern.AskTimeoutException: Ask timed out on [Actor[akka://hello-impl-application/system/sharding/HelloEntity#976224651]] after [10000 ms]. Message of type [com.lightbend.lagom.javadsl.persistence.CommandEnvelope]. A typical reason for `AskTimeoutException` is that the recipient actor didn't send a reply.\r\n\tat akka.pattern.PromiseActorRef$.$anonfun$defaultOnTimeout$1(AskSupport.scala:635)\r\n\tat akka.pattern.PromiseActorRef$.$anonfun$apply$1(AskSupport.scala:650)\r\n\tat akka.actor.Scheduler$$anon$4.run(Scheduler.scala:205)\r\n\tat scala.concurrent.Future$InternalCallbackExecutor$.unbatchedExecute(Future.scala:870)\r\n\tat scala.concurrent.BatchingExecutor.execute(BatchingExecutor.scala:109)\r\n\tat scala.concurrent.BatchingExecutor.execute$(BatchingExecutor.scala:103)\r\n\tat scala.concurrent.Future$InternalCallbackExecutor$.execute(Future.scala:868)\r\n\tat akka.actor.LightArrayRevolverScheduler$TaskHolder.executeTask(LightArrayRevolverScheduler.scala:328)\r\n\tat akka.actor.LightArrayRevolverScheduler$$anon$4.executeBucket$1(LightArrayRevolverScheduler.scala:279)\r\n\tat akka.actor.LightArrayRevolverScheduler$$anon$4.nextTick(LightArrayRevolverScheduler.scala:283)\r\n\tat akka.actor.LightArrayRevolverScheduler$$anon$4.run(LightArrayRevolverScheduler.scala:235)\r\n\tat java.lang.Thread.run(Thread.java:748)\r\n"}

1 个答案:

答案 0 :(得分:0)

在使用MySQL时,我们需要创建数据库本身。在Cassandra中,它会在conf文件中定义名称后创建键空间,但在MySQL中,我们必须手动创建一个数据库,例如 test ->

  

创建数据库测试;

那么您将不会遇到Ask超时异常。