我正在通过intellij运行一个火花工作。作业执行并给我输出。我需要将此作为jar文件发送到服务器并运行,但是当我尝试执行sbt assembly
时,它会抛出以下错误:
[error] Not a valid command: assembly
[error] Not a valid project ID: assembly
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: assembly
[error] assembly
我的sbt版本是0.13.8
下面是我的build.sbt文件:
import sbt._, Keys._
name := "mobilewalla"
version := "1.0"
scalaVersion := "2.11.7"
libraryDependencies ++= Seq("org.apache.spark" %% "spark-core" % "2.0.0",
"org.apache.spark" %% "spark-sql" % "2.0.0")
我在项目目录下添加了一个文件assembly.sbt。它包含:
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.3")
我在这里缺少什么
答案 0 :(得分:1)
在build.sbt
中添加这些行assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case x => MergeStrategy.first
}
mainClass in assembly := Some("com.SparkMain")
resolvers += "spray repo" at "http://repo.spray.io"
assemblyJarName in assembly := "streaming-api.jar"
并在plugins.sbt文件中包含这些行
addSbtPlugin("io.spray" % "sbt-revolver" % "0.7.2")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.13.0")
答案 1 :(得分:0)
要将多个罐子组装成一个,你需要在项目目录下的plugins.sbt中添加以下插件。
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.3")
如果你需要自定义组装的jar来触发特定的MainClass,请参见assembly.sbt
import sbtassembly.Plugin.AssemblyKeys._
Project.inConfig(Compile)(baseAssemblySettings)
mainClass in (Compile, assembly) := Some("<main application name with package path>")
jarName in (Compile, assembly) := s"${name.value}-${version.value}-dist.jar"
//below is merge strategy to make what all file need to exclude or include
mergeStrategy in (Compile, assembly) <<= (mergeStrategy in (Compile, assembly)) {
(old) => {
case PathList(ps @ _*) if ps.last endsWith ".html" =>MergeStrategy.first
case "META-INF/MANIFEST.MF" => MergeStrategy.discard
case x => old(x)
}
}