Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala 为什么错误与跨版本后缀冲突?_Scala_Sbt_Akka_Spray - Fatal编程技术网

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

Scala 为什么错误与跨版本后缀冲突?,scala,sbt,akka,spray,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

当我试图在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版本指定为2.11
  • 您已经为reactivemongo和poi Scala库明确指定了Scala版本(2.10)
  • 修复方法是对这两个库也使用
    %%
    操作符

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

    这就是
    %%
    运算符的用途。将声明的Scala版本(在您的示例中为2.11)附加到工件名称。

    我尝试使用%%,但没有成功。我已使用

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

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

    libraryDependencies += "org.apache.spark" %% "spark-core" % "1.6.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>
    
    
    ...
    ...
    

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

    不,那些库无法通过%%operator:(@rodrigocifuntesgómez)找到,这意味着它们还没有迁移到Scala 2.11。我会选择2.10(
    scalaVersion:=“2.10.4”
    )目前,另一种选择是开始从两个2.10库中排除可传递依赖项,这很可能会因为其他类路径冲突而给您带来麻烦。最有可能是在运行时。这个答案在我看来是正确的。如果您同意,Rodrigo,如果您批准这一点,将有助于其他患者(当然,这会奖励作者花时间准备答案)。
    <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>