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!

4

2 回答 2

6

事实上(正如错误所解释的那样),play.db.anorm._2.2.0 版本中没有包。尝试import anorm._改用。

于 2013-10-26T16:30:55.943 回答
1

您需要以下库

slick
play-jdbc
anorm

这就是我的依赖项的样子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
)

在Maven 中央存储库中搜索最新版本的库

于 2015-04-29T08:32:35.260 回答