Lagom与MySQL Db连接

问题描述 投票:1回答:1

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

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

Aplikeshnkkf

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

之后,我运行应用程序,我得到以下错误。这是什么错误。我是拉格姆的新手所以请详细解释。

{"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"}
mysql playframework akka lagom
1个回答
2
投票

在使用MySQL时,我们需要自己创建数据库。在Cassandra中,它在conf文件中定义名称后创建了键空间,但在MySQL中,我们必须手动创建一个数据库说测试你的情况 - >

创建数据库测试;

然后你不会面对Ask超时异常。

© www.soinside.com 2019 - 2024. All rights reserved.