scala 为什么会出现Conflicting cross-version suffixes的错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23617920/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 06:15:30  来源:igfitidea点击:

Why is the error Conflicting cross-version suffixes?

scalasbtakkaspray

提问by Rodrigo Cifuentes Gómez

I'm getting this error when I try to compile a Scala project in sbt.

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

This is my build.sbtfile:

这是我的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
  )
}

Any suggestions?

有什么建议?

回答by Ionu? G. Stan

The conflicts appear because:

出现冲突是因为:

  1. you've specified your Scala version to be 2.11
  2. you've explicitly specified the Scala version (2.10) for the reactivemongo and poi-scala libraries.
  1. 您已将 Scala 版本指定为 2.11
  2. 您已经为reactivemongo 和poi-scala 库明确指定了Scala 版本(2.10)。

The fix is to use the %%operator for those two libraries as well.

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

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

That's the purpose of the %%operator. To append the declared Scala version (2.11 in your case) to the artifact name.

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

回答by Mayukh

I had the same problem and I simply removed the scalaVersion tag from my sbt file and modified the line

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

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

to

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

and the problem went away.

问题就解决了。

回答by Prasath Rao

I have tried using %% but it didn't work. I have manually excluded it using

我试过使用 %% 但它没有用。我已经手动排除它使用

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

回答by Roman Kazanovskyi

To investigate who is caller you can use a plugin but an easier way to look into target/scala-2.*/resolution-cache/reports/. There is Ivy's resolution report for each configuration. Look for *-compile.xmland *-test.xmland search for conflicting library. You can see similar with

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

This should tell you the caller of the module.

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