Office of Secret Intelligence

Who taught you to be a spy, fucking Gallagher!?!

RE: Playing With Scala: Building a Small Web App with Play 2.4, Play-Slick and Postgres

Hi Devin,

I had a look at your build.sbt (here https://github.com/dhoss/steel/blob/master/build.sbt), and there are a couple of things you should change. First, remove the dependency to jdbc module. You are using the play-slick module for all database accesses, so you should not need to Play jdbc. In fact, as soon as you update to play-slick 1.0.0-RC2 (which was released last week, together with Play 2.4.0-RC3), you will get an exception similar to https://playframework.com/documentation/2.4.0-RC3/PlaySlickFAQ#A-binding-to-play.api.db.DBApi-was-already-configured. Second, update to play-slick 1.0.0-RC2 because RC1 had an annoying issue (https://github.com/playframework/play-slick/issues/245) that could prevent starting your app.

Otherwise, it's a good article. I'll see how I can clarify why you need both

slick.dbs.default.driver="slick.driver.PostgresDriver$"  slick.dbs.default.db.driver="org.postgresql.Driver"

in your application.conf. But, in a nutshell, the first is the Slick driver (which you will be using in your code), while the second is the JDBC driver which is going to be used by Slick backend. See the Slick documentation for DatabaseConfig http://slick.typesafe.com/doc/3.0.0/database.html#databaseconfig

Thanks for trying it out, and taking the time to write about your experience.


Sign in to reply

Replies:

i am having the same problem

rovisionException: 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 parameter 0 at repo.StudentRepo.<init>(StudentRepo.scala:17) while locating repo.StudentRepo for parameter 0 at controllers.LoginController.<init>(LoginController.scala:24) while locating controllers.LoginController for parameter 6 at router.Routes.<init>(Routes.scala:47) 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

my build.sbt

 

name := """demo"""

version := "1.0-SNAPSHOT"

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

scalaVersion := "2.11.7"

libraryDependencies ++= Seq(
cache,
ws,
specs2 % Test,
"org.webjars" %% "webjars-play" % "2.5.0-1",
"org.webjars" % "bootstrap" % "3.1.1-2",
"com.adrianhurt" %% "play-bootstrap" % "1.0-P25-B3",
"com.typesafe.play" %% "play-slick" % "1.1.1",
"com.h2database" % "h2" % "1.4.187" ,
"org.postgresql" % "postgresql" % "9.4-1206-jdbc4",
"com.adrianhurt" %% "play-bootstrap" % "1.0-P25-B3",
"ch.qos.logback" % "logback-classic" % "1.1.3",
"com.typesafe.play" %% "play-slick-evolutions" % "1.1.1",
"com.typesafe.slick" %% "slick-hikaricp" % "3.1.1",
"com.typesafe.slick" %% "slick" % "3.1.1",
"org.seleniumhq.selenium" % "selenium-server" % "2.52.0",
"org.seleniumhq.selenium" % "selenium-firefox-driver" % "2.52.0",
"org.scalatest" %% "scalatest" % "2.2.1" % "test",
"org.scalatestplus" %% "play" % "1.4.0-M3" % "test",
"org.seleniumhq.selenium" % "selenium-htmlunit-driver" % "2.52.0"

)
javaOptions in Test += "-Dconfig.file=conf/test.conf"

coverageExcludedPackages :="<empty>;router\\..*;"

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

// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator


resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"



 

Reply

Wow! My first comments on this blog.  Thanks for taking the time to check this out.  

I'll be sure to make the changes you mentioned, and update the article as well.

 

Again, much appreciation for setting me straight, I've got lots more to write about in the coming weeks.

Reply