由于 StaticLoggerBinder.class 中的重复数据删除错误,Scala SBT 程序集无法合并 [英] Scala SBT Assembly cannot merge due to de-duplication error in StaticLoggerBinder.class

查看:127
本文介绍了由于 StaticLoggerBinder.class 中的重复数据删除错误,Scala SBT 程序集无法合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是我不能再使用 sbt-assembly 插件,因为在从事这个项目的几个人之间出现了某种依赖合并问题.

My problem is I can no longer use the sbt-assembly plugin because some kind of dependency merge problem creeped in, between a couple people working on this project.

运行'sbt assembly'时的问题:

The problem when I run 'sbt assembly' :

[error] 合并时遇到 3 个错误java.lang.RuntimeException:重复数据删除:发现不同的文件内容在下面的:/Users/aris.vlasakakis/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.1.2.jar:org/slf4j/impl/StaticLoggerBinder.class/Users/aris.vlasakakis/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.6.1.jar:org/slf4j/impl/StaticLoggerBinder.class重复数据删除:在以下位置找到不同的文件内容:/Users/aris.vlasakakis/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.1.2.jar:org/slf4j/impl/StaticMDCBinder.class/Users/aris.vlasakakis/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.6.1.jar:org/slf4j/impl/StaticMDCBinder.class重复数据删除:在以下位置找到不同的文件内容:/Users/aris.vlasakakis/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.1.2.jar:org/slf4j/impl/StaticMarkerBinder.class/Users/aris.vlasakakis/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.6.1.jar:org/slf4j/impl/StaticMarkerBinder.class在 sbtassembly.Assembly$.applyStrategies(Assembly.scala:140)在 sbtassembly.Assembly$.x$1$lzycompute$1(Assembly.scala:25)在 sbtassembly.Assembly$.x$1$1(Assembly.scala:23)在 sbtassembly.Assembly$.stratMapping$lzycompute$1(Assembly.scala:23)在 sbtassembly.Assembly$.stratMapping$1(Assembly.scala:23)在 sbtassembly.Assembly$.inputs$lzycompute$1(Assembly.scala:67)在 sbtassembly.Assembly$.inputs$1(Assembly.scala:57)

[error] 3 errors were encountered during merge java.lang.RuntimeException: deduplicate: different file contents found in the following: /Users/aris.vlasakakis/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.1.2.jar:org/slf4j/impl/StaticLoggerBinder.class /Users/aris.vlasakakis/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.6.1.jar:org/slf4j/impl/StaticLoggerBinder.class deduplicate: different file contents found in the following: /Users/aris.vlasakakis/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.1.2.jar:org/slf4j/impl/StaticMDCBinder.class /Users/aris.vlasakakis/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.6.1.jar:org/slf4j/impl/StaticMDCBinder.class deduplicate: different file contents found in the following: /Users/aris.vlasakakis/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.1.2.jar:org/slf4j/impl/StaticMarkerBinder.class /Users/aris.vlasakakis/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.6.1.jar:org/slf4j/impl/StaticMarkerBinder.class at sbtassembly.Assembly$.applyStrategies(Assembly.scala:140) at sbtassembly.Assembly$.x$1$lzycompute$1(Assembly.scala:25) at sbtassembly.Assembly$.x$1$1(Assembly.scala:23) at sbtassembly.Assembly$.stratMapping$lzycompute$1(Assembly.scala:23) at sbtassembly.Assembly$.stratMapping$1(Assembly.scala:23) at sbtassembly.Assembly$.inputs$lzycompute$1(Assembly.scala:67) at sbtassembly.Assembly$.inputs$1(Assembly.scala:57)

...等等

I am using SBT-assembly 0.13.0, and here is the build.sbt

name := "metamorphosis"

version := "0.10.0"

scalaVersion := "2.10.4"

lazy val common = RootProject(file("../"))

val main = Project(id = "bridge", base = file(".")).dependsOn(common)

//excludeDependencies += "org.apache.logging.log4j"

resolvers ++= Seq(
//  "Akka Snapshot Repository" at "http://repo.akka.io/snapshots/",
  "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/",
  "Sonatype OSS Releases"  at "http://oss.sonatype.org/content/repositories/releases/"
)

libraryDependencies ++= Seq(
  "com.github.nscala-time" %% "nscala-time" % "1.8.0",
  "com.sclasen" %% "akka-kafka" % "0.0.10" % "compile",
  "com.typesafe.akka" %% "akka-actor" % "2.3.2",
  "org.codehaus.groovy" % "groovy" % "2.3.7",
  "com.typesafe.scala-logging" %% "scala-logging-slf4j" % "2.1.2",
  "ch.qos.logback" % "logback-classic" % "1.1.2",
  "ch.qos.logback.contrib" % "logback-json-classic" % "0.1.2",
  "ch.qos.logback.contrib" % "logback-jackson" % "0.1.2",
  "org.slf4j" % "slf4j-api" % "1.7.7",
  "com.fasterxml.jackson.core" % "jackson-databind" % "2.2.2",
  "org.clapper" %% "argot" % "1.0.3",
  "com.typesafe" % "config" % "1.2.1",
  "net.ceedubs" %% "ficus" % "1.0.1",
  "com.typesafe.play" %% "anorm" % "2.3.6",
  "org.json4s" %% "json4s-native" % "3.2.10",
  "org.json4s" %% "json4s-jackson" % "3.2.10",
  "com.github.tototoshi" %% "scala-csv" % "1.1.2",
  "org.scalatest" %% "scalatest" % "2.2.2",
  "junit" % "junit" % "4.11",
  "org.apache.kafka" %% "kafka" % "0.8.1.1"
    exclude("javax.jms", "jms")
    exclude("com.sun.jdmk", "jmxtools")
    exclude("com.sun.jmx", "jmxri")
    exclude("org.slf4j", "slf4j-simple")
)

mainClass in assembly := Some("com.company.kafka.agent.MetamorphosisActor")

关于如何解决这个合并问题的任何线索?

Any clues on how I can even figure out how to fix this merge problem?

谢谢!

推荐答案

上一个答案提供了所有必需的反馈,但实际上并未提供任何解决方案或尝试的步骤.

我的错误:

[error] (project/*:assembly) deduplicate: different file contents found in the following:
[error] /home/user/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.2.3.jar:org/slf4j/impl/StaticLoggerBinder.class
[error] /home/user/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.7.10.jar:org/slf4j/impl/StaticLoggerBinder.class
[error] deduplicate: different file contents found in the following:
[error] /home/user/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.2.3.jar:org/slf4j/impl/StaticMDCBinder.class
[error] /home/user/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.7.10.jar:org/slf4j/impl/StaticMDCBinder.class
[error] deduplicate: different file contents found in the following:
[error] /home/user/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.2.3.jar:org/slf4j/impl/StaticMarkerBinder.class
[error] /home/user/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.7.10.jar:org/slf4j/impl/StaticMarkerBinder.class

推荐方式

追踪冲突的依赖.例如,我不想要这些类:

Recommended way

track down conflicting dependency. For example, I do not want those classes:

org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.7.10.jar:org/slf4j/impl/StaticLoggerBinder.class
org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.7.10.jar:org/slf4j/impl/StaticMDCBinder.class
org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.7.10.jar:org/slf4j/impl/StaticMarkerBinder.class

调用 sbt(并确保使用 sbt-dependency-graph 插件):

Call sbt (and make sure to use sbt-dependency-graph plugin):

whatDependsOn org.slf4j slf4j-log4j12 1.7.10

返回一个列表:

[info] org.slf4j:slf4j-log4j12:1.7.10
[info]   +-org.apache.hadoop:hadoop-auth:2.8.0
[info]   | +-org.apache.hadoop:hadoop-common:2.8.0
[info]   |   +-com.github.atais:test_2.11:0.0.3 [S]
[info]   |   
[info]   +-org.apache.hadoop:hadoop-common:2.8.0
[info]   | +com.github.atais:test_2.11:0.0.3 [S]
[info]   | 
[info]   +-org.apache.zookeeper:zookeeper:3.4.6
[info]     +-org.apache.curator:curator-client:2.7.1
[info]     | +-org.apache.curator:curator-framework:2.7.1
[info]     | | +-org.apache.curator:curator-recipes:2.7.1
[info]     | | | +-org.apache.hadoop:hadoop-common:2.8.0
[info]     | | |   +-com.github.atais:test_2.11:0.0.3 [S]
[info]     | | |   
[info]     | | +-org.apache.hadoop:hadoop-auth:2.8.0
[info]     | |   +-org.apache.hadoop:hadoop-common:2.8.0
[info]     | |     +-com.github.atais:test_2.11:0.0.3 [S]
[info]     | |     
[info]     | +-org.apache.hadoop:hadoop-common:2.8.0
[info]     |   +-com.github.atais:test_2.11:0.0.3 [S]
[info]     |   
[info]     +-org.apache.curator:curator-framework:2.7.1
[info]     | +-org.apache.curator:curator-recipes:2.7.1
[info]     | | +-org.apache.hadoop:hadoop-common:2.8.0
[info]     | |   +-com.github.atais:test_2.11:0.0.3 [S]
[info]     | |   
[info]     | +-org.apache.hadoop:hadoop-auth:2.8.0
[info]     |   +-org.apache.hadoop:hadoop-common:2.8.0
[info]     |     +-com.github.atais:test_2.11:0.0.3 [S]
[info]     |     
[info]     +-org.apache.curator:curator-recipes:2.7.1
[info]     | +-org.apache.hadoop:hadoop-common:2.8.0
[info]     |   +-com.github.atais:test_2.11:0.0.3 [S]
[info]     |   
[info]     +-org.apache.hadoop:hadoop-auth:2.8.0
[info]     | +-org.apache.hadoop:hadoop-common:2.8.0
[info]     |   +-com.github.atais:test_2.11:0.0.3 [S]
[info]     |   
[info]     +-org.apache.hadoop:hadoop-common:2.8.0
[info]       +-com.github.atais:test_2.11:0.0.3 [S]

我需要追踪 hadoop-common 依赖,因为它是将 com.github.atais:test_2.11:0.0.3 连接到不需要的 <代码>org.slf4j:slf4j-log4j12:1.7.10

I need to track down hadoop-common dependency since it is the one that connects com.github.atais:test_2.11:0.0.3 to the unwanted org.slf4j:slf4j-log4j12:1.7.10

并修改它:

libraryDependencies += "org.apache.hadoop" % "hadoop-common" % "2.8.1" exclude("org.slf4j", "slf4j-log4j12")

简单的方法

只需为冲突路径添加合并策略标志:

Easy way

simply add the merging strategy flag for conflicting paths:

assemblyMergeStrategy in assembly := {
  ...
  case PathList("org", "slf4j", xs@_*) => MergeStrategy.first
  case x => (assemblyMergeStrategy in assembly).value(x)
}

这篇关于由于 StaticLoggerBinder.class 中的重复数据删除错误,Scala SBT 程序集无法合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆