使用 slick 在 mysql 中创建架构时出错
Getting error while creating schema in mysql using slick
错误:
value <> is not a member of (slick.lifted.Rep[String], slick.lifted.Rep[String], slick.lifted.Rep[String])
def * : ProvenShape[Employee] = (id, name, dept) <> (Employee.tupled, Employee.unapply)
我的 build.sbt 看起来像这样:
name := "AkkaHttpDemo"
version := "0.1"
scalaVersion := "2.13.3"
lazy val root = project in file(".")
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.6.8" ,
"com.typesafe.akka" %% "akka-stream" % "2.6.8",
"com.typesafe.akka" %% "akka-http" % "10.2.0",
"com.typesafe.slick" %% "slick" % "3.3.2",
"com.typesafe.slick" %% "slick-hikaricp" % "3.3.2",
"org.slf4j" % "slf4j-nop" % "1.6.6" % Test,
"mysql" % "mysql-connector-java" % "8.0.21"
)
Table 架构如下所示:
package services
import akka.stream.scaladsl._
import slick.jdbc.MySQLProfile._
import slick.ast.ScalaBaseType.stringType
import slick.lifted._
import slick.util._
trait EmployeeStore {
class EmployeeStoreImpl(tag: Tag) extends Table[Employee](tag, _schemaName = Some("MYSCHEMA"),"EMPL") {
def id= column[String]("empid")
def name = column[String]("name")
def dept = column[String]("dept")
def * : ProvenShape[Employee] = (id, name, dept) <> (Employee.tupled, Employee.unapply)
}
val dict = TableQuery[EmployeeStoreImpl]
}
注意*:当我尝试给出下面的代码时也得到错误
dict.schema.create
Cannot resolve symbol schema
您需要导入 Slick API:
import slick.jdbc.MySQLProfile.api._
你也可以把<>
换成更方便的:
def * = (id, name, dept).mapTo[Employee]
您可能不需要 slick.ast
、slick.lifted
或 slick.util
导入,但非常感谢您在示例中包含完整的导入列表。
错误:
value <> is not a member of (slick.lifted.Rep[String], slick.lifted.Rep[String], slick.lifted.Rep[String])
def * : ProvenShape[Employee] = (id, name, dept) <> (Employee.tupled, Employee.unapply)
我的 build.sbt 看起来像这样:
name := "AkkaHttpDemo"
version := "0.1"
scalaVersion := "2.13.3"
lazy val root = project in file(".")
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.6.8" ,
"com.typesafe.akka" %% "akka-stream" % "2.6.8",
"com.typesafe.akka" %% "akka-http" % "10.2.0",
"com.typesafe.slick" %% "slick" % "3.3.2",
"com.typesafe.slick" %% "slick-hikaricp" % "3.3.2",
"org.slf4j" % "slf4j-nop" % "1.6.6" % Test,
"mysql" % "mysql-connector-java" % "8.0.21"
)
Table 架构如下所示:
package services
import akka.stream.scaladsl._
import slick.jdbc.MySQLProfile._
import slick.ast.ScalaBaseType.stringType
import slick.lifted._
import slick.util._
trait EmployeeStore {
class EmployeeStoreImpl(tag: Tag) extends Table[Employee](tag, _schemaName = Some("MYSCHEMA"),"EMPL") {
def id= column[String]("empid")
def name = column[String]("name")
def dept = column[String]("dept")
def * : ProvenShape[Employee] = (id, name, dept) <> (Employee.tupled, Employee.unapply)
}
val dict = TableQuery[EmployeeStoreImpl]
}
注意*:当我尝试给出下面的代码时也得到错误
dict.schema.create
Cannot resolve symbol schema
您需要导入 Slick API:
import slick.jdbc.MySQLProfile.api._
你也可以把<>
换成更方便的:
def * = (id, name, dept).mapTo[Employee]
您可能不需要 slick.ast
、slick.lifted
或 slick.util
导入,但非常感谢您在示例中包含完整的导入列表。