why slick2.0 can not find the TableQuery class in playframework 2.2.1?

My model is:

import scala.slick.driver.PostgresDriver.simple._
import scala.slick.lifted.TableQuery


class User(tag: Tag) extends Table[(Int, String, String)](tag, "User") {
def id = column[Int]("SUP_ID", O.PrimaryKey)
def name = column[String]("SUP_NAME")
def street = column[String]("STREET")
def * = (id, name, street)
}

//val users = TableQuery[Users]
val users=TableQuery[User]

I do this follow the example on

http://slick.typesafe.com/doc/2.0.1-RC1/gettingstarted.html#slick-examples

when I compile the error is:

[myslickclick] $ compile
[info] Compiling 9 Scala sources and 1 Java source to C:assigmentmyslickclick
targetscala-2.10classes...
[error] C:assigmentmyslickclickappmodelUser.scala:15: expected class or obj
ect definition
[error] val Users=TableQuery[User]
[error] ^
[error] one error found
[error] (compile:compile) Compilation failed
[error] Total time: 0 s, completed 03/03/2014 3:55:49 PM

I use slick 2.0.1 rc1. I think it is same, but there is still can not recognize the class.


That's because you cannot declare values outside of classes or objects.

Your val users=TableQuery[User] should be in an object, like a UserDAO :

object UserDAO {
  val users = TableQuery[User]

  def all: ...

  def byId: ...
}
链接地址: http://www.djcxy.com/p/95140.html

上一篇: 如何在Play 2.4上安装ReactiveMongo?

下一篇: 为什么slick2.0在playframework 2.2.1中找不到TableQuery类?