2016-03-27 30 views
-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目錄)。

+0

您正在使用哪種Java版本? –

+0

指示java和anorm版本 – cchantep

+0

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中看到。 –

回答

1

Play 2.4需要Java 8.所以我的猜測是Play Anorm也期待Java 8。錯誤表明它正在嘗試使用已在Java 8中添加的java.util.time

相關問題