为什么slick2.0在playframework 2.2.1中找不到TableQuery类?
我的模特是:
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]
我这样做的例子
http://slick.typesafe.com/doc/2.0.1-RC1/gettingstarted.html#slick-examples
当我编译的错误是:
[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
我使用光滑的2.0.1 rc1。 我认为它是一样的,但仍然不能承认这个班级。
这是因为你不能在类或对象之外声明值。
你的val users=TableQuery[User]
应该在一个对象中,像一个UserDAO
:
object UserDAO {
val users = TableQuery[User]
def all: ...
def byId: ...
}
链接地址: http://www.djcxy.com/p/95139.html
上一篇: why slick2.0 can not find the TableQuery class in playframework 2.2.1?