0

我使用 scala+play2+slick2:

val subject = TableQuery[Subjects]

主题是我的 tableQuery

在控制器中我定义了一个功能:

import scala.slick.driver.PostgresDriver.simple._
def index = DBAction {implicit rs =>

Ok(views.html.list_subject.render("Hello from Scala", (subject.drop(0).map(i => (i.id, i.name, i.describe,i.sub_resource)).run)
    ))
}

错误是:

[info] Loading project definition from G:\testprojects\slickplay\project
[info] Set current project to slickplay (in build file:/G:/testprojects/slickpla
y/)
[info] Compiling 6 Scala sources to G:\testprojects\slickplay\target\scala-2.10\
classes...
[error] G:\testprojects\slickplay\app\controllers\MainController.scala:12: could
not find implicit value for parameter session: scala.slick.jdbc.JdbcBackend#Ses
sionDef
[error]     Ok(views.html.list_subject.render("Hello from Scala", (subject.drop(
0).map(i => (i.id, i.name, i.describe,i.sub_resource)).run)
[error]
                                                   ^
[error] one error found
[error] (compile:compile) Compilation failed
[error] Total time: 9 s, completed 11/04/2014 2:23:57 PM

有没有 scala+play2+slick2 和使用 Form 的例子?有谁知道如何返回 (i.id, i.name, i.describe,i.sub_resource) 列表?

4

1 回答 1

2

尝试导入

import play.api.db.slick._
import play.api.db.slick.Config.driver.simple._

如果您使用的是 DBAction,我推测它来自play-slick 插件

于 2014-04-11T13:18:52.927 回答