-1
文件的src/main /斯卡拉/ Test.scala:ANORM缺失或无效依赖检测,同时加载的类文件 'JavaTimeColumn.class'
import anorm.SQL
import anorm.SqlParser.{str, float}
import anorm._
object Test {
def main(args: Array[String]) {
val dbUrl = "jdbc:mysql://localhost:3306/test"
Class.forName("org.gjt.mm.mysql.Driver").newInstance()
implicit val conn: java.sql.Connection = java.sql.DriverManager.getConnection(dbUrl)
val parser = str("name") ~ float("weight") map { case name ~ f => (name -> f) }
val result = SQL("select name, weight from products").as(parser.single)
}
}
文件build.sbt:
scalaVersion := "2.11.7"
libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.38"
libraryDependencies += "com.typesafe.play" %% "anorm" % "2.5.0"
来看,它:
$ sbt sbt-version
[info] Set current project to test (in build file:/home/david/test/)
[info] 0.13.11
$ sbt run
[info] Set current project to test (in build file:/home/david/test/)
[info] Compiling 1 Scala source to /home/david/test/target/scala-2.11/classes...
[error] missing or invalid dependency detected while loading class file 'JavaTimeColumn.class'.
[error] Could not access type ZonedDateTime in value java.time,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'JavaTimeColumn.class' was compiled against an incompatible version of java.time.
[error] ^
[error] (compile:compileIncremental) Compilation failed
我用尽了一切从头开始:新的Ubuntu虚拟机,安装SBT和运行这个(所以,没有以前的.m2目录下,名.bstñ或.ivy目录)。
您正在使用哪种Java版本? –
指示java和anorm版本 – cchantep
java版本1.7.0(1.7.0_65在'ubuntu/usr/lib/jvm/java-7-openjdk-amd64/jre'和1.7.0_40'/ Library/Java/JavaVirtualMachines /在OSX上的jdk1.7.0_40.jdk/Contents/Home/jre')。 anorm版本2.5.0,你可以在build.sbt中看到。 –