5

I'm trying to make my first tests with Scala and with Play framework.

I have installed play 2.2.0, which seems to be the last version, with the standalone package. After that, I've been able to create a new application, compile and run it.

I've tried to start to use Anorm package to access to the database, but I've found a blocking error which I can't find on the docs. I don't know if that means that is so obvious, but after adding:

package controllers

import play.api._
import play.api.mvc._
import play.db.anorm._ //(this is the new line)

object Application extends Controller {
  def index = Action {
    Ok(views.html.index("Your new application is ready."))
  }
}

It fails with:

object db is not a member of package play

I've seen this:

Where they talk about adding the dependency to jdbc, which seems to be already in my build.sbt.

libraryDependencies ++= Seq(
  jdbc,
  anorm,
  cache
)   

I've also found this thread here:

But I can't find a build.scala file on my project. Not using any IDE by now, just play console (run & compile commands).

Thanks a lot!

Community
  • 1
  • 1
Jacob
  • 1,886
  • 2
  • 25
  • 40
  • Are you by chance defining your own `package play`? That would shadow the Play framework. – 0__ Oct 26 '13 at 13:39
  • Thanks, but no:(. I've edited the post to include how the controller's file looks like. – Jacob Oct 26 '13 at 15:06

2 Answers2

6

In fact (as the error explains), there is no package play.db.anorm._ in version 2.2.0. Try use import anorm._ instead.

Yall
  • 261
  • 1
  • 6
  • Thanks Yall, that was all. Seems that part of the docs/tutorials still have references to the previous import. – Jacob Oct 27 '13 at 10:25
1

You need the following libraries

slick
play-jdbc
anorm

This is how my dependencies look like in build.sbt :

libraryDependencies ++= Seq(
  "com.typesafe.slick" % "slick_2.10" % "2.1.0",
  "org.postgresql" % "postgresql" % "9.4-1201-jdbc41",
  "com.typesafe.play" % "play-jdbc_2.10" % "2.4.0-RC1",
  cache,
  anorm
)

Search for the latest version of library at Maven Central Repository

Hanxue
  • 12,243
  • 18
  • 88
  • 130