当我尝试使用sbt 0.13.5(以及Java 1.7.0_45)运行sbt test
时,我遇到了以下错误:
[error](test:executeTests)java.lang.NoSuchMethodError: scala.Predef $ .ArrowAssoc(Ljava /郎/对象;)Ljava /郎/对象;
这是 build.sbt 我使用:
version := "0.1"
scalaVersion := "2.10.3"
resolvers ++= Seq(
"spray" at "http://repo.spray.io",
"Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
)
libraryDependencies ++= Seq(
"io.spray" %% "spray-json" % "1.2.5",
"com.typesafe.akka" %% "akka-actor" % "2.2.4",
"com.typesafe.akka" %% "akka-slf4j" % "2.2.4",
"com.typesafe.akka" %% "akka-testkit" % "2.2.4",
"com.github.kxbmap" %% "configs" % "0.2.1",
"junit" % "junit" % "4.8.1" % "test",
"ch.qos.logback" % "logback-classic" % "1.0.13",
"io.spray" % "spray-can" % "1.2.1",
"io.spray" % "spray-routing" % "1.2.1",
"io.spray" % "spray-testkit" % "1.2.1",
"org.scalatest" % "scalatest_2.10" % "2.0" % "test",
"com.typesafe.akka" %% "akka-testkit" % "2.1.4"% "test",
"org.mockito" % "mockito-core" % "1.9.5",
"org.specs2" %% "specs2" % "2.1.1" % "test"
)
我尝试删除~/.sbt
和~/.ivy2
目录,并在每个目录后执行sbt clean
。
这是完整的堆栈跟踪:
sbt test
[info] Loading project definition from /Users/arumehta/cds_torii/project
[info] Set current project to cds_torii (in build file:/Users/arumehta/cds_torii/)
java.lang.NoSuchMethodError: scala.Predef$.ArrowAssoc(Ljava/lang/Object;)Ljava/lang/Object;
at org.scalatest.tools.FriendlyParamsTranslator$.<init>(FriendlyParamsTranslator.scala:23)
at org.scalatest.tools.FriendlyParamsTranslator$.<clinit>(FriendlyParamsTranslator.scala)
at org.scalatest.tools.Framework.runner(Framework.scala:1064)
at sbt.Defaults$$anonfun$createTestRunners$1.apply(Defaults.scala:515)
at sbt.Defaults$$anonfun$createTestRunners$1.apply(Defaults.scala:510)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.immutable.Map$Map2.foreach(Map.scala:130)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
at scala.collection.AbstractTraversable.map(Traversable.scala:105)
at sbt.Defaults$.createTestRunners(Defaults.scala:510)
at sbt.Defaults$.allTestGroupsTask(Defaults.scala:525)
at sbt.Defaults$$anonfun$testTasks$4.apply(Defaults.scala:392)
at sbt.Defaults$$anonfun$testTasks$4.apply(Defaults.scala:392)
at scala.Function8$$anonfun$tupled$1.apply(Function8.scala:35)
at scala.Function8$$anonfun$tupled$1.apply(Function8.scala:34)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
at sbt.std.Transform$$anon$4.work(System.scala:64)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
at sbt.Execute.work(Execute.scala:244)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
[error] (test:executeTests) java.lang.NoSuchMethodError: scala.Predef$.ArrowAssoc(Ljava/lang/Object;)Ljava/lang/Object;
[error] Total time: 1 s, completed Aug 1, 2014 3:49:24 PM
答案 0 :(得分:9)
我遇到了同样的错误,并注意到sbt实际上正在编译scala 2.10作为目标。将scalaVersion
更改为2.11.4
即可解决问题。
答案 1 :(得分:1)
从项目文件夹
执行以下操作它会像魅力一样......