简体   繁体   English

使用SBT制作Spark Fat Jar的正确方法

[英]Proper way to make a Spark Fat Jar using SBT

I need a Fat Jar with Spark because I'm creating a custom node for Knime. 我需要一个带有Spark的Fat Jar,因为我正在为Knime创建一个自定义节点。 Basically it's a self-contained jar executed inside Knime and I assume a Fat Jar is the only way to spawn a local Spark Job. 基本上,这是在Knime中执行的一个自包含的jar,我认为Fat Jar是产生本地Spark Job的唯一方法。 Eventually we will go on submitting a job to a remote cluster but for now I need it to spawn this way. 最终,我们将继续向远程集群提交作业,但现在我需要以这种方式生成它。

That said, I made a Fat Jar using this: https://github.com/sbt/sbt-assembly 也就是说,我使用以下工具制作了一个胖子罐: https : //github.com/sbt/sbt-assembly

I made an empty sbt project, included Spark-core in the dependencies and assembled the Jar. 我做了一个空的sbt项目,在依赖项中包含了Spark-core,并组装了Jar。 I added it to the manifest of my custom Knime node and tried to spawn a simple job (pararellize a collection, collect it and print it). 我将其添加到自定义Knime节点的清单中,并尝试产生一个简单的工作(派生出一个集合,对其进行收集并打印)。 It starts but I get this error: 它开始了,但是我得到这个错误:

No configuration setting found for key 'akka.version' 找不到键“ akka.version”的配置设置

I have no idea how to solve it. 我不知道如何解决。

Edit: this is my build.sbt 编辑:这是我的build.sbt

name := "SparkFatJar"

version := "1.0"

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  "org.apache.spark" %% "spark-core" % "1.3.0"
)


libraryDependencies +=  "com.typesafe.akka" %% "akka-actor" % "2.3.8"

assemblyJarName in assembly := "SparkFatJar.jar"

assemblyMergeStrategy in assembly := {
  case PathList("META-INF", xs @ _*) => MergeStrategy.discard
  case x => MergeStrategy.first
}

I've found this mergestrategy for Spark somewhere on the internet but I can't find the source right now. 我已经在互联网上的某个地方找到了Spark的这种合并策略,但现在找不到源。

I think the issue is with how you've setup assemblyMergeStrategy . 我认为问题在于您如何设置assemblyMergeStrategy Try this: 尝试这个:

assemblyMergeStrategy in assembly := {
  case PathList("META-INF", xs @ _*) => MergeStrategy.discard
  case "application.conf"            => MergeStrategy.concat
  case "reference.conf"              => MergeStrategy.concat
  case x =>
    val baseStrategy = (assemblyMergeStrategy in assembly).value
    baseStrategy(x)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM