Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala 光滑创建表_Scala_Slick_Slick 2.0 - Fatal编程技术网

Scala 光滑创建表

Scala 光滑创建表,scala,slick,slick-2.0,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) exten

我将使用下面的代码创建简单表,如教程中所示:

 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运行良好!您的依赖项有问题。检查build.sbtAlso请注意,您的代码中有一个概念性错误,Person不应该有可选id,因为该列是必需的,因此永远不会为空,不确定您为什么选择该列作为选项。@mohit依赖项需要什么?我的问题与光滑示例中的相同。请在问题中添加build.sbt,这将有助于调试。关于糟糕的符号参照,有很多问题。你可以试试谷歌搜索。