Cannot connect to mysql database using play-slick 1.0.1 / slick 3.0: configuration error

I am trying to switch from anoma to slick using play 2.4.2 and get a configuration error:

play.api.Configuration$$anon$1: Configuration error[Cannot connect to database [dethcs]] at play.api.Configuration$.configError(Configuration.scala:178) ~[play_2.11-2.4.0.jar:2.4.0] ... Caused by: slick.SlickException: Error getting instance of Slick driver "slick.driver.MySQLDriver" ... Caused by: java.lang.NoSuchMethodException: slick.driver.MySQLDriver.<init>() 

The previous answers I found on SO focused on having the right MySQL driver and other dependencies. I believe that my build.sbt covers the relevant databases, including:

 libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.36" libraryDependencies += "com.typesafe.play" %% "play-slick" % "1.0.1" libraryDependencies += "com.typesafe.play" %% "play-slick-evolutions" % "1.0.1" 

Relevant lines in my application.conf application:

 slick.dbs.dethcs.db.driver="com.mysql.jdbc.Driver" slick.dbs.dethcs.driver="slick.driver.MySQLDriver" slick.dbs.dethcs.user="redacted" slick.dbs.dethcs.db.url="jdbc:mysql://localhost/mydb" slick.dbs.dethcs.password="redacted" 

I would be grateful for any suggestions on how to fix this - I suppose this is something stupid, but it was very difficult for me to get the documentation and examples that apply to later versions of slick - and can provide additional information if that helps.

+1
source share
1 answer

I have not tried myself, but it looks like you are referring to the MySQLDriver class instead of the corresponding object. Put the final $ in it, and you should be good to go:

slick.dbs.dethcs.driver="slick.driver.MySQLDriver$"

+6
source

Source: https://habr.com/ru/post/1257876/


All Articles