gpt4 book ai didi

scala - 启动时播放错误: No implementation for play. api.db.Database已绑定(bind)

转载 作者:行者123 更新时间:2023-12-02 06:00:08 25 4
gpt4 key购买 nike

当我尝试运行 Play 应用程序 (Play 2.5.4) 时,出现以下错误:

ProvisionException: Unable to provision, see the following errors:

1) No implementation for play.api.db.Database was bound.
while locating play.api.db.Database
for parameter 0 at ds.qb.manage.ManageQueryBuilder.<init>(ManageQueryBuilder.scala:30)
while locating ds.qb.manage.ManageQueryBuilder
for parameter 16 at router.Routes.<init>(Routes.scala:107)
while locating router.Routes
while locating play.api.inject.RoutesProvider
while locating play.api.routing.Router
for parameter 0 at play.api.http.JavaCompatibleHttpRequestHandler.<init>(HttpRequestHandler.scala:200)
while locating play.api.http.JavaCompatibleHttpRequestHandler
while locating play.api.http.HttpRequestHandler
for parameter 4 at play.api.DefaultApplication.<init>(Application.scala:221)
at play.api.DefaultApplication.class(Application.scala:221)
while locating play.api.DefaultApplication
while locating play.api.Application

这是我的数据库设置,有什么想法吗?我有两次定义,因为我通过 Slick 和 JDBC 访问数据库。

play.db {
# The combination of these two settings results in "db.default" as the
# default JDBC pool:
config = "db"
default = "default"

# Play uses HikariCP as the default connection pool. You can override
# settings by changing the prototype:
#prototype {
# Sets a fixed JDBC connection pool size of 50
#hikaricp.minimumIdle = 50
#hikaricp.maximumPoolSize = 50
#}
}

db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost:3306/db2"
db.default.username=root
db.default.password=xxxxx


db2 = {
url = "jdbc:mysql://localhost:3306/db2"
driver = com.mysql.jdbc.Driver
connectionPool = disabled
keepAliveConnection = true
user=root
password=xxxxxx
}

更新

build.sbt 文件:

name := """myapp"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.7"

libraryDependencies ++= Seq(
jdbc,
cache,
ws,
"org.scalatestplus.play" %% "scalatestplus-play" % "1.5.1" % Test
)

libraryDependencies += "com.typesafe.slick" %% "slick" % "3.1.1"
libraryDependencies += "com.typesafe.play" %% "play-slick" % "2.0.0"
libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.18"
libraryDependencies += "org.pivot4j" % "pivot4j-core" % "0.9"
libraryDependencies += "org.scalaz" %% "scalaz-core" % "7.1.0"

// properties file
libraryDependencies += "com.typesafe" % "config" % "1.3.0"

libraryDependencies += "org.slf4j" % "slf4j-nop" % "1.6.4"
libraryDependencies += "log4j" % "log4j" % "1.2.14"

resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"

// mondrian
resolvers += "Pentaho Releases" at "http://repository.pentaho.org/artifactory/repo/"

最佳答案

就我而言,application.conf 没有正确的数据库参数

示例

  db.default.driver = org.h2.Driver
db.default.url = "jdbc:h2:mem:play"
db.default.username = sa
db.default.password = ""

关于scala - 启动时播放错误: No implementation for play. api.db.Database已绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38825728/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com