我写了这个非常简单的代码,我在互联网上的很多地方都看到过
import scala.slick.driver.H2Driver.simple._
import scala.concurrent.ExecutionContext.Implicits.global
import slick.jdbc.meta._
import scala.concurrent._
import ExecutionContext.Implicits.global
import scala.concurrent.duration._
object Helper {
def printTableNames() : Unit = {
val db = Database.forConfig("test1")
db.withSession {implicit session =>
val x = Await.result(MTable.getTables().list(), Duration.Inf).toList
x.foreach(println)
}
}
}
但这在运行时给了我一个神秘的错误
[error] /Users/abhi/ScalaProjects/SlickTest/src/test/scala/HelloSpec.scala:13: overloaded method value getTables with alternatives:
[error] => slick.profile.BasicStreamingAction[Vector[slick.jdbc.meta.MTable],slick.jdbc.meta.MTable,slick.dbio.Effect.Read] <and>
[error] (namePattern: String)slick.profile.BasicStreamingAction[Vector[slick.jdbc.meta.MTable],slick.jdbc.meta.MTable,slick.dbio.Effect.Read] <and>
[error] (cat: Option[String],schemaPattern: Option[String],namePattern: Option[String],types: Option[Seq[String]])slick.profile.BasicStreamingAction[Vector[slick.jdbc.meta.MTable],slick.jdbc.meta.MTable,slick.dbio.Effect.Read]
[error] cannot be applied to ()
[error] val x = Await.result(MTable.getTables().list(), Duration.Inf).toList
[error] ^
[error] one error found
[error] (test:compileIncremental) Compilation failed
[error] Total time: 1 s, completed Jun 27, 2015 12:34:03 AM