【问题标题】:Why is the error Conflicting cross-version suffixes?为什么会出现 Conflicting cross-version suffixes 的错误?
【发布时间】:2014-06-30 08:10:00
【问题描述】:

当我尝试在 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
  )
}

有什么建议吗?

【问题讨论】:

    标签: scala sbt akka spray


    【解决方案1】:

    出现冲突是因为:

    1. 您已将 Scala 版本指定为 2.11
    2. 您已为 reactivemongo 和 poi-scala 库明确指定了 Scala 版本 (2.10)。

    解决方法是对这两个库也使用%% 运算符。

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

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

    【讨论】:

    • 不,使用 %% 运算符找不到那些库 :(
    • @RodrigoCifuentesGómez 这意味着他们还没有迁移到 Scala 2.11。我暂时选择 2.10 (scalaVersion := "2.10.4")。另一种方法是开始从两个 2.10 库中排除传递依赖项,这很可能由于其他类路径冲突而让您头疼。最有可能在运行时。
    • 这个答案看起来是正确的,而且对我来说很重要。如果您同意,罗德里戈,如果您同意,这将有助于其他患者(当然,这将奖励作者花时间准备答案)。
    【解决方案2】:

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

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

    到

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

    问题就解决了。

    【讨论】:

      【解决方案3】:

      我曾尝试使用 %%,但没有成功。我已经手动排除了它使用

      ("org.reactivemongo" % "reactivemongo" % reactiveMongoVersion)
          .exclude("com.typesafe.akka", "akka-actor_2.10")
          .exclude("org.scalaz", "scalaz-effect")
          .exclude("org.scalaz", "scalaz-core")
      

      【讨论】:

        【解决方案4】:

        要调查谁是调用者,您可以使用插件,但更简单的方法是查看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>
        

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2022-12-02
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-04-22
          • 2011-04-23
          相关资源
          最近更新 更多