加载 class 文件 'JavaTimeColumn.class' 时检测到异常缺失或无效依赖项

Anorm missing or invalid dependency detected while loading class file 'JavaTimeColumn.class'

文件src/main/scala/Test.scala:

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、.sbt 或 .ivy 目录)。

Play 2.4 需要 Java 8。所以我猜 Play Anorm 也需要 Java 8。该错误表明它正在尝试使用在 Java 8.

中添加的 java.util.time