我正在学习本教程,http://slick.typesafe.com/doc/3.1.0/gettingstarted.html#populating-the-database。当我复制代码时,上面写着“无法解析符号.”我的代码
我在使用IntelliJ
app/控制器/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等等。我是不是遗漏了其他的东西?或者是我的密码
发布于 2015-11-06 16:41:59
它至少不能解析suppliers和coffees,因为您忽略了它们的定义:
val suppliers = TableQuery[Suppliers]
val coffees = TableQuery[Coffees]https://stackoverflow.com/questions/33567653
复制相似问题