2017-04-13 23 views
1

我正在嘗試設置一個簡單的使用slick和postgres的2.5應用程序,但似乎無法通過錯誤。
我得到的錯誤是使用postgres驅動程序發揮漂亮的數據庫配置問題

[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.driverslick.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 
... 

我想把我的頭髮拉到這裏,找不到任何其他資源來看。有誰知道發生了什麼事?

+0

也許'slick.dbs.default.driver =「slick.driver.PostgresDriver $」'而不是'Profile'? –

+0

@ insan-e對不起,我有一個錯字,我嘗試過'slick.driver.PostgresDriver',我想我也嘗試過'slick.driver.PostgresDriver $'以及相同的結果,但讓我再試一次案件。 – kag0

+0

@ insan-e whelp,回去嘗試'slick.jdbc.PostgresProfile $',現在可以使用了。如果你想提交答案,我會接受它,否則我會在稍後自我回答。 – kag0

回答

3

果然,通過insan-e的推薦,我所要做的只是添加一個$。所以slick.dbs.default.driver應該是"slick.jdbc.PostgresProfile$"

+0

那是什麼意思在這種情況下?爲什麼需要它? – freakman

+0

@freakman它與編譯的類名稱有關,請參閱https://stackoverflow.com/questions/11388840/java-compiled-classes-contain-dollar-signs – kag0

+1

之類的內容,但它在某些需要傳遞的地方很奇怪完整的類名稱與$和其他沒有它的人 – freakman