标题翻译
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 = <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
得分: 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("."))
.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",
// To provide an implementation of JAXB-API, which is required by 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"
)
)
专注分享java语言的经验与见解,让所有开发者获益!
评论