光滑创建表

时间:2014-11-19 12:20:15

标签: scala slick slick-2.0

我在教程中使用下一代创建简单表的代码:

 import scala.slick.driver.H2Driver.simple._
 import scala.slick._
 import scala.slick.lifted.{ProvenShape, TableQuery}

 object MyModels {

   case class Person(id: Option[Long], name: String)

   class Persons(tag: Tag) extends Table[Person](tag, "persons") {
     def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
     def name = column[String]("name")

     def *  = (id.?, name) <> (Person.tupled, Person.unapply)
   }
   lazy val sources = TableQuery[Persons]
}

但是当我尝试编译它时,我得到:

[error] bad symbolic reference. A signature in package.class refers to type compileTimeOnly
[error] in package scala.annotation which is not available.
[error] It may be completely missing from the current classpath, or the version on
[error] the classpath might be incompatible with the version used when compiling package.class.
[error] /home/user/example/src/main/scala/example/mymodels/MyModels.scala:16: Reference to method anyToToShapedValue in trait Implicits should not have survived past type checking,
[error] it should have been processed and eliminated during expansion of an enclosing macro.    
[error]      def *  = (id.?, name) <> (Person.tupled, Person.unapply)
[error]               ^
[error] /home/user/example/src/main/scala/example/mymodels/MyModels.scala:16: Reference to method tupled in trait Function2 should not have survived past type checking,
[error] it should have been processed and eliminated during expansion of an enclosing macro.
[error]      def *  = (id.?, name) <> (Person.tupled, Person.unapply)
[error]                                       ^
[error] /home/user/example/src/main/scala/example/mymodels/MyModels.scala:16: Reference to method tuple2Shape in trait ShapeLowPriority2 should not have survived past type checking,
[error] it should have been processed and eliminated during expansion of an enclosing macro.
[error]      def *  = (id.?, name) <> (Person.tupled, Person.unapply)
[error]                            ^
[error] four errors found
[error] (compile:compile) Compilation failed

为什么呢?以及如何解决它?

Scala-2.10.4和slick-2.1.0

0 个答案:

没有答案