我遇到了一个akka.ConfigurationException: Akka JAR version [2.1.0] does not match the provided config version [2.2.3]
. 我的猜测是,不知何故,$SCALA_HOME/lib/akka-actors.jar
它与 SBT 管理的 Akka JAR 一起进入了类路径。
我创建了一个简单的独立 SBT 项目来演示这个问题(见下文)。我的 $SCALA_HOME 指向 Scala 2.10.3。在 Build.scala 我明确设置scalaHome
为$SCALA_HOME
project/Build.scala
import sbt._
import sbt.Keys._
object ApplicationBuild extends Build {
val appName = "akka-version-problem"
val appVersion = "0.1-SNAPSHOT"
val getJars = TaskKey[Unit]("get-jars")
val getJarsTask = getJars <<= (target, fullClasspath in Compile) map { (target, cp) =>
println(cp map { _.data } filter { _.getAbsolutePath.contains("lib") } mkString "\n")
println(cp map { _.data } filter { _.getAbsolutePath.contains("akka") } mkString "\n")
}
lazy val root = Project("root", file(".")).settings(
scalaVersion := "2.10.3",
scalaHome := Some(file(System.getenv("SCALA_HOME"))),
autoScalaLibrary := false,
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.2.3"
),
getJarsTask
)
}
src/main/scala/com/example/Main.scala
package com.example
import akka.actor.ActorSystem
object Main extends App {
val system = ActorSystem("AkkaDemoSystem")
system.shutdown()
}
当我运行时,我在输出sbt get-jars
中看不到当我运行时,我得到:$SCALA_HOME/lib/akka-actors.jar
sbt run
[error] (run-main) 44c2d48a-8899-43f9-804b-55cbf739b08bakka.ConfigurationException: Akka JAR version [2.1.0] does not match the provided config version [2.2.3]
44c2d48a-8899-43f9-804b-55cbf739b08bakka.ConfigurationException: Akka JAR version [2.1.0] does not match the provided config version [2.2.3]
at akka.actor.ActorSystem$Settings.<init>(ActorSystem.scala:172)
at akka.actor.ActorSystemImpl.<init>(ActorSystem.scala:465)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:111)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:93)
at com.example.Main$delayedInit$body.apply(Main.scala:6)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.collection.immutable.List.foreach(List.scala:318)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
at scala.App$class.main(App.scala:71)
at com.example.Main$.main(Main.scala:5)
at com.example.Main.main(Main.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
我错过了一些明显的东西吗?有没有其他人遇到过这个?