[英]No implementation Slick DatabaseConfigProvider was bound
I have just created a dummy project and try to integrate Play with Slick. 我刚刚创建了一个虚拟项目,并尝试将Play与Slick集成在一起。 I followed the official tutorial but unfortunatelly did not manage do run it properly. 我遵循了官方教程,但是很遗憾,没有设法正确运行它。 Everytime I try to run the app I get following error: 每当我尝试运行该应用程序时,都会出现以下错误:
play.api.UnexpectedException: Unexpected exception[ProvisionException: Unable to provision, see the following errors:
1) No implementation for play.api.db.slick.DatabaseConfigProvider was bound.
while locating play.api.db.slick.DatabaseConfigProvider
for the 1st parameter of com.reciper.repository.UserRepository.<init>(UserRepository.scala:13)
Here are my configs: 这是我的配置:
build.sbt build.sbt
scalaVersion := "2.12.2"
libraryDependencies += guice
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % Test
libraryDependencies += "com.typesafe.play" %% "play-slick" % "3.0.3"
libraryDependencies += "com.typesafe.play" %% "play-slick-evolutions" % "3.0.3"
libraryDependencies += "org.postgresql" % "postgresql" % "42.2.4"
application.conf application.conf
play.evolutions {
autoApply = true
}
#Slick for Play
slick.profile = "slick.jdbc.PostgresProfile$"
slick.db.driver = "org.postgresql.Driver"
slick.db.url = "jdbc:postgresql://localhost:5432/reciper"
slick.db.user = "postgres"
slick.db.password = "postgres"
UserRepository.scala UserRepository.scala
@Singleton
class UserRepository @Inject()(protected val dbConfigProvider: DatabaseConfigProvider)
(implicit executionContext: ExecutionContext) extends HasDatabaseConfigProvider[PostgresProfile] { ..codehere.. }
HomeController.scala HomeController.scala
@Singleton
class HomeController @Inject()(repo: UserRepository) {...}
plugins.sbt plugins.sbt
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.13")
I have been struggling with it for more than 3 days now and lost my hope that it will actually work.. tried many options, none worked 我已经为它苦苦挣扎了3天多了,我失去了希望它能真正起作用的希望。
Do you know what is missing or wrong? 您知道什么遗漏或错了吗? Let me know if you need any other file Thanks! 让我知道您是否需要其他文件谢谢!
Following configuration in application.conf
works 在application.conf
以下配置有效
build.sbt build.sbt
"com.typesafe.play" %% "play-slick" % "3.0.3"
application.conf application.conf
slick.dbs.default.driver="slick.driver.PostgresDriver$"
slick.dbs.default.db.driver="org.postgresql.Driver"
slick.dbs.default.db.url="jdbc:postgresql://ec2-54-217-243-228.eu-west-1.compute.amazonaws.com:5432/d344onl0761ji5"
slick.dbs.default.db.user=user
slick.dbs.default.db.password="pass"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.