Play Framework 2.8.x MySQL连接问题

huangapple 未分类评论57阅读模式
标题翻译

Play Framework 2.8.x MySQL Connection Issue

问题

application.conf

application.secret = <secret code>
application.session.maxAge = 5m
application.session.secure = true
play.http.parser.maxMemoryBuffer = 512M
application.langs = "en"

db.default.driver = com.mysql.jdbc.Driver
db.default.url = "jdbc:mysql://localhost:3306/<db_name>"
db.default.username = "username"
db.default.password = "password"

db.default.logSql=true

play.evolutions.enabled=false

ebean.default = ["package.to.models.*"]

I unable to find what's wrong with this issue i refer play framework official documentation

seems it says unable to inject dependancies

Error injecting constructor, javax.persistence.PersistenceException: java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 29996ms

build.sbt

lazy val root = (project in file("."))
  .enablePlugins(PlayJava, PlayEbean)
  .settings(
    name := """project_name""",
    organization := "com.package",
    version := "1.0-SNAPSHOT",
    scalaVersion := "2.13.1",
    libraryDependencies ++= Seq(
        guice,
        jdbc,
        "mysql" % "mysql-connector-java" % "8.0.19",
        "it.innove" % "play2-pdf" % "1.10.0",
    ),
    scalacOptions ++= Seq(
      "-feature",
      "-deprecation",
      "-Xfatal-warnings"
    )
  )

[1]: https://www.playframework.com/documentation/2.8.x/

如需进一步帮助,请随时提问。

英文翻译

application.conf

application.secret = &lt;secret code&gt;
application.session.maxAge = 5m
application.session.secure = true
play.http.parser.maxMemoryBuffer = 512M
application.langs = &quot;en&quot;

db.default.driver = com.mysql.jdbc.Driver
db.default.url = &quot;jdbc:mysql://localhost:3306/&lt;db_name&gt;&quot;
db.default.username = &quot;username&quot;
db.default.password = &quot;password&quot;

db.default.logSql=true

play.evolutions.enabled=false

ebean.default = [&quot;package.to.models.*&quot;]

I unable to find what's wrong with this issue i refer play framework official documentation

seems it says unable to inject dependancies

Error injecting constructor, javax.persistence.PersistenceException: java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 29996ms

build.sbt

lazy val root = (project in file(&quot;.&quot;))
  .enablePlugins(PlayJava, PlayEbean)
  .settings(
    name := &quot;&quot;&quot;project_name&quot;&quot;&quot;,
    organization := &quot;com.package&quot;,
    version := &quot;1.0-SNAPSHOT&quot;,
    scalaVersion := &quot;2.13.1&quot;,
    libraryDependencies ++= Seq(
        guice,
        jdbc,
        &quot;mysql&quot; % &quot;mysql-connector-java&quot; % &quot;8.0.19&quot;,
        &quot;it.innove&quot; % &quot;play2-pdf&quot; % &quot;1.10.0&quot;,
    ),
    scalacOptions ++= Seq(
      &quot;-feature&quot;,
      &quot;-deprecation&quot;,
      &quot;-Xfatal-warnings&quot;
    )
  )

答案1

得分: 0

问题是缺少JAXB-API依赖项,Eban ORM需要它。

请按照下面的方式更新 build.sbt 文件:

lazy val root = (project in file("."))
  .enablePlugins(PlayJava, PlayEbean)
  .settings(
    name := """project_name""",
    organization := "com.package",
    version := "1.0-SNAPSHOT",
    scalaVersion := "2.13.1",
    libraryDependencies ++= Seq(
        guice,
        jdbc,
        "mysql" % "mysql-connector-java" % "8.0.19",
        "it.innove" % "play2-pdf" % "1.10.0",
        // 为了提供 JAXB-API 的实现,这是 Ebean 所需的。
        "javax.xml.bind" % "jaxb-api" % "2.3.1",
        "javax.activation" % "activation" % "1.1.1",
        "org.glassfish.jaxb" % "jaxb-runtime" % "2.3.2"
    ),
    scalacOptions ++= Seq(
      "-feature",
      "-deprecation",
      "-Xfatal-warnings"
    )
  )
英文翻译

Problem is it is missing JAXB-API dependancies it is required by Eban ORM

update the build.sbt file as bellow

lazy val root = (project in file(&quot;.&quot;))
  .enablePlugins(PlayJava, PlayEbean)
  .settings(
    name := &quot;&quot;&quot;project_name&quot;&quot;&quot;,
    organization := &quot;com.package&quot;,
    version := &quot;1.0-SNAPSHOT&quot;,
    scalaVersion := &quot;2.13.1&quot;,
    libraryDependencies ++= Seq(
        guice,
        jdbc,
        &quot;mysql&quot; % &quot;mysql-connector-java&quot; % &quot;8.0.19&quot;,
        &quot;it.innove&quot; % &quot;play2-pdf&quot; % &quot;1.10.0&quot;,
        // To provide an implementation of JAXB-API, which is required by Ebean.
        &quot;javax.xml.bind&quot; % &quot;jaxb-api&quot; % &quot;2.3.1&quot;,
        &quot;javax.activation&quot; % &quot;activation&quot; % &quot;1.1.1&quot;,
        &quot;org.glassfish.jaxb&quot; % &quot;jaxb-runtime&quot; % &quot;2.3.2&quot;,
    ),
    scalacOptions ++= Seq(
      &quot;-feature&quot;,
      &quot;-deprecation&quot;,
      &quot;-Xfatal-warnings&quot;
    )
  )

huangapple
  • 本文由 发表于 2020年3月16日 14:38:30
  • 转载请务必保留本文链接:https://java.coder-hub.com/60701371.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定