简体   繁体   English

Lagom与MySQL Db连接

[英]Lagom With MySQL Db connection

I want to connect lagom to MySQL db, I download a project which is created in Lagom site. 我想将lagom连接到MySQL数据库,我下载了在Lagom站点中创建的项目。 I added the following dependency in to the hello-impl pom, and applicaiont.conf configure the db details. 我在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 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

after that I run the application i got the following error. 之后,我运行该应用程序,出现以下错误。 what is the mistake. 有什么错误。 i'm new in lagom so please explain detail. 我是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"}

While using MySQL we need to create the database itself. 在使用MySQL时,我们需要创建数据库本身。 In Cassandra, it creates keyspace after defining a name in conf file but in MySQL, we have to manually create a database say test in your case -> 在Cassandra中,它在conf文件中定义了名称之后创建了键空间,但是在MySQL中,我们必须手动创建数据库,例如在您的情况下说test- >

create database test; 创建数据库测试;

then you won't face Ask timed out exception. 那么您将不会遇到Ask超时异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM