我正在尝试用slick和postgres设置一个简单的play 2.5应用程序,但似乎无法克服错误。
我所犯的错误是
[error] p.a.d.s.DefaultSlickApi - Failed to create Slick database config for key default.
slick.SlickException: Error getting instance of profile "slick.jdbc.PostgresProfile"
...
Caused by: java.lang.InstantiationException: slick.jdbc.PostgresProfile
...
Caused by: java.lang.NoSuchMethodException: slick.jdbc.PostgresProfile.<init>()
...我的application.conf中有以下内容
slick.dbs.default {
driver = "slick.jdbc.PostgresProfile"
db = {
driver = "org.postgresql.Driver"
user = postgres
host = localhost
port = 5432
password = ""
host = ${?EVENTUAL_DB_HOST}
port = ${?EVENTUAL_DB_PORT}
user = ${?EVENTUAL_DB_USER}
password = ${?EVENTUAL_DB_PW}
url = "jdbc:postgresql://"${slick.dbs.default.db.host}":"${slick.dbs.default.db.port}"/"${slick.dbs.default.db.user}
}
}而这些在我的依赖关系中
"com.typesafe.play" %% "play-slick" % "2.1.0",
"com.typesafe.slick" %% "slick-codegen" % "3.1.1",
"com.github.tminglei" %% "slick-pg" % "0.15.0-RC", //"0.14.6",
"org.postgresql" % "postgresql" % "42.0.0"如果我将slick.dbs.default.driver更改为slick.driver.PostgresDriver (显然现在已不再推荐),我将得到
[error] p.a.d.s.DefaultSlickApi - Failed to create Slick database config for key default.
slick.SlickException: Error getting instance of profile "slick.driver.PostgresDriver"
...
Caused by: java.lang.ClassNotFoundException: slick.driver.PostgresDriver
...我想把头发拔出来,却找不到其他的资源。有人知道这是怎么回事吗?
发布于 2017-04-17 06:28:07
当然,根据insan-e的推荐,我所要做的就是添加一个$。所以slick.dbs.default.driver应该是"slick.jdbc.PostgresProfile$"。
https://stackoverflow.com/questions/43399137
复制相似问题