为什么错误冲突的跨版本后缀?

时间:2014-05-12 20:07:49

标签: scala sbt akka spray

当我尝试在sbt中编译Scala项目时,我收到此错误。

Modules were resolved with conflicting cross-version suffixes in {file:/home/seven3n/caja/Flujo_de_caja/}flujo_de_caja:
[error]    com.typesafe.akka:akka-actor _2.11, _2.10
[error]    org.scalaz:scalaz-effect _2.10, _2.11
[error]    org.scalaz:scalaz-core _2.10, _2.11
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) Conflicting cross-version suffixes in: com.typesafe.akka:akka-actor, org.scalaz:scalaz-effect, org.scalaz:scalaz-core

这是我的 build.sbt 文件:

scalaVersion := "2.11.0"

resolvers ++= Seq(
  "Sonatype snapshots repository" at "https://oss.sonatype.org/content/repositories/snapshots/",
  "Spray repository" at "http://repo.spray.io/",
  "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
)

libraryDependencies ++= {
  val akkaVersion = "2.3.2"
  val sprayVersion = "1.3.1-20140423"
  val sprayJsonVersion = "1.2.6"
  val reactiveMongoVersion = "0.11.0-SNAPSHOT"
  val scalaTestVersion = "2.1.5"
  val specs2Version = "2.3.11"
  val foloneVersion = "0.12-SNAPSHOT"
  Seq(
    "com.typesafe.akka" %% "akka-actor"        % akkaVersion,
    "com.typesafe.akka" %% "akka-testkit"      % akkaVersion,
    "io.spray"          %% "spray-can"         % sprayVersion,
    "io.spray"          %% "spray-routing"     % sprayVersion,
    "io.spray"          %% "spray-testkit"     % sprayVersion,
    "io.spray"          %% "spray-json"        % sprayJsonVersion,
    "org.reactivemongo" % "reactivemongo_2.10" % reactiveMongoVersion,
    "org.scalatest"     %% "scalatest"         % scalaTestVersion % "test",
    "org.specs2"        %% "specs2"            % specs2Version % "test",
    "info.folone"       % "poi-scala_2.10"     % foloneVersion
  )
}

有什么建议吗?

4 个答案:

答案 0 :(得分:40)

出现冲突是因为:

  1. 您已将Scala版本指定为2.11
  2. 您已为reactivemongo和poi-scala库明确指定了Scala版本(2.10)。
  3. 修复方法是对这两个库使用%%运算符。

    "org.reactivemongo" %% "reactivemongo" % reactiveMongoVersion,
    "info.folone"       %% "poi-scala"     % foloneVersion
    

    这是%%运营商的目的。要将声明的Scala版本(在您的情况下为2.11)附加到工件名称。

答案 1 :(得分:4)

我遇到了同样的问题,我只是从我的sbt文件中删除了scalaVersion标记并修改了该行

libraryDependencies += "org.apache.spark" %% "spark-core" % "1.6.0"

libraryDependencies += "org.apache.spark" % "spark-core_2.11" % "1.6.0"

问题消失了。

答案 2 :(得分:2)

我尝试过使用%%,但它没有用。我已经使用

手动排除了它
("org.reactivemongo" % "reactivemongo" % reactiveMongoVersion)
    .exclude("com.typesafe.akka", "akka-actor_2.10")
    .exclude("org.scalaz", "scalaz-effect")
    .exclude("org.scalaz", "scalaz-core")

答案 3 :(得分:0)

要调查谁是呼叫者,您可以使用插件,但更简单的方法来研究target/scala-2.*/resolution-cache/reports/。 每个配置都有Ivy的分辨率报告。 查找*-compile.xml*-test.xml,然后搜索有冲突的库。 您可以通过

查看类似内容
<module organisation="com.github.nscala-time" name="nscala-time_2.11">
    ...
    <caller organisation="com.tumblr" name="colossus-metrics_2.11" conf="compile, runtime" rev="1.2.0" rev-constraint-default="1.2.0" rev-constraint-dynamic="1.2.0" callerrev="0.7.2-RC1"/>
    ...
</module>

这应该告诉您模块的调用者。