我遵循本教程http://slick.typesafe.com/doc/3.1.0/gettingstarted.html#populating-the-database。当我复制该代码时,它说“无法解析符号......” my code
我正在使用IntelliJ
应用程序/控制器/ tables.scala:
import slick.driver.H2Driver.api._
import slick.lifted.{ProvenShape, ForeignKeyQuery}
class Suppliers(tag: Tag)
extends Table[(Int, String, String, String, String, String)](tag, "SUPPLIERS") {
def id: Rep[Int] = column[Int]("SUP_ID", O.PrimaryKey)
def name: Rep[String] = column[String]("SUP_NAME")
def street: Rep[String] = column[String]("STREET")
def city: Rep[String] = column[String]("CITY")
def state: Rep[String] = column[String]("STATE")
def zip: Rep[String] = column[String]("ZIP")
def * : ProvenShape[(Int, String, String, String, String, String)] =
(id, name, street, city, state, zip)
}
class Coffees(tag: Tag)
extends Table[(String, Int, Double, Int, Int)](tag, "COFFEES") {
def name: Rep[String] = column[String]("COF_NAME", O.PrimaryKey)
def supID: Rep[Int] = column[Int]("SUP_ID")
def price: Rep[Double] = column[Double]("PRICE")
def sales: Rep[Int] = column[Int]("SALES")
def total: Rep[Int] = column[Int]("TOTAL")
def * : ProvenShape[(String, Int, Double, Int, Int)] =
(name, supID, price, sales, total)
def supplier: ForeignKeyQuery[Suppliers, (Int, String, String, String, String, String)] =
foreignKey("SUP_FK", supID, TableQuery[Suppliers])(_.id)
}
application.conf:
h2mem1 = {
url = "jdbc:h2:mem:test"
driver = org.h2.Driver
connectionPool = disabled
keepAliveConnection = true
}
// im using jdbc:h2:~/test as my URL in H2 Console(port 8082)
// currently using Generic H2 (Embedded)
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:test;MODE=MYSQL;DB_CLOSE_DELAY=-1"
db.default.username=sa
db.default.password=""
构建
libraryDependencies ++= Seq(
jdbc,
cache,
ws,
specs2 % Test,
"com.typesafe.slick" %% "slick" % "3.1.0",
"com.h2database" % "h2" % "1.4.190",
"org.slf4j" % "slf4j-nop" % "1.6.4",
"com.typesafe.slick" %% "slick-codegen" % "3.1.0"
)
libraryDependencies += evolutions
我使用IntelliJ IDE,得到了我需要的所有插件:play,scala等。我错过了别的什么吗?或者是我的代码
答案 0 :(得分:0)
它至少无法解决suppliers
和coffees
,因为你错过了他们的定义:
val suppliers = TableQuery[Suppliers]
val coffees = TableQuery[Coffees]