gpt4 book ai didi

scala - sbt assemblyMergeStrategy 不工作

转载 作者:行者123 更新时间:2023-12-04 17:59:38 34 4
gpt4 key购买 nike

我写了下面的build.sbt文件

lazy val root = (project in file(".")).settings(
name := "SparkStreaming1",
organization := "abhi",
version := "1.0",
scalaVersion := "2.11.8",
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-streaming" % "1.6.0" % "provided",
"org.apache.spark" %% "spark-core" % "1.6.0" % "provided",
"org.apache.spark" %% "spark-streaming-twitter" % "1.6.0" force()
),
mainClass in assembly := Some("com.abhi.TendingHashTags"),
assemblyMergeStrategy in assembly := {
case PathList("javax", "servlet", xs @ _*) => MergeStrategy.first
case PathList(ps @ _*) if ps.last endsWith ".html" => MergeStrategy.first
case "application.conf" => MergeStrategy.concat
case "UnusedStubClass.class" => MergeStrategy.first
case "unwanted.txt" => MergeStrategy.discard
case x =>
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
}
)

您可以看到我已经为 UnusedStubClass.class 定义了一个合并策略,但是当我执行 sbt clean assembly 时仍然出现错误

[error] 1 error was encountered during merge
java.lang.RuntimeException: deduplicate: different file contents found in the following:
/Users/abhishek.srivastava/.ivy2/cache/org.apache.spark/spark-streaming-twitter_2.11/jars/spark-streaming-twitter_2.11-1.6.0.jar:org/apache/spark/unused/UnusedStubClass.class
/Users/abhishek.srivastava/.ivy2/cache/org.spark-project.spark/unused/jars/unused-1.0.0.jar:org/apache/spark/unused/UnusedStubClass.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)
at sbtassembly.Assembly$.apply(Assembly.scala:83)
at sbtassembly.Assembly$$anonfun$assemblyTask$1.apply(Assembly.scala:241)
at sbtassembly.Assembly$$anonfun$assemblyTask$1.apply(Assembly.scala:238)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:235)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
[error] (*:assembly) deduplicate: different file contents found in the following:
[error] /Users/abhishek.srivastava/.ivy2/cache/org.apache.spark/spark-streaming-twitter_2.11/jars/spark-streaming-twitter_2.11-1.6.0.jar:org/apache/spark/unused/UnusedStubClass.class
[error] /Users/abhishek.srivastava/.ivy2/cache/org.spark-project.spark/unused/jars/unused-1.0.0.jar:org/apache/spark/unused/UnusedStubClass.class
[error] Total time: 12 s, completed May 10, 2016 11:01:09 PM

为什么我指定的assemblyMergeStrategy不生效?

最佳答案

因为您在根目录中有针对 UnusedStubClass.class 的策略,而不是针对 org/apache/spark/unused/UnusedStubClass.class 的策略。请改用 PathList("org", "apache", "spark", "unused", "UnusedStubClass.class")。或者像 PathList(xs @ _*) if xs.last == "UnusedStubClass.class" 如果你想在任何包中处理 UnusedStubClass.class

关于scala - sbt assemblyMergeStrategy 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37152902/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com