问题描述
当我尝试使用 sbt 0.13.5(和 Java 1.7.0_45)运行 sbt test
时遇到以下错误:
I have been running into the following error when I try to run sbt test
with sbt 0.13.5 (and Java 1.7.0_45):
[错误] (test:executeTests) java.lang.NoSuchMethodError:scala.Predef$.ArrowAssoc(Ljava/lang/Object;)Ljava/lang/Object;
这是我使用的 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
.
I have tried removing ~/.sbt
and ~/.ivy2
directories, and was doing sbt clean
after each.
这是完整的堆栈跟踪:
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
推荐答案
我遇到了同样的错误,并注意到 sbt 实际上正在编译为 scala 2.10 作为目标.将 scalaVersion
更改为 2.11.4
解决了它.
I had the same error and noticed that sbt was actually compiling to scala 2.10 as a target. Changing scalaVersion
to 2.11.4
resolved it.
这篇关于java.lang.NoSuchMethodError: scala.Predef$.ArrowAssoc 执行“sbt test"的原因是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!