1.首先在 project/plugins.sbt: 下加入这段代码:app
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
2.先对project 执行sbt 看看能不能经过 记住要在机子上装好Git
3.在根目录建立assembly.sbt文件,内容以下:this
import AssemblyKeys._ // put this at the top of the file assemblySettings // your assembly settings here
以后就能够sbt assembly
来打包了,生成./target/scala_x.x.x/projectname-assembly-x.x.x.jar
4.若是想更详细的配置assembly,能够这样spa
在assembly.sbt内写入:scala
import AssemblyKeys._ assemblySettings jarName in assembly := "spark_sbt.jar" test in assembly := {} mainClass in assembly := Some( "Spark_Test") assemblyOption in packageDependency ~= { _.copy(appendContentHash = true) } mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) => { case PathList(ps @ _*) if ps.last endsWith "axiom.xml" => MergeStrategy.filterDistinctLines case PathList(ps @ _*) if ps.last endsWith "Log.class" => MergeStrategy.first case PathList(ps @ _*) if ps.last endsWith "LogConfigurationException.class" => MergeStrategy.first case PathList(ps @ _*) if ps.last endsWith "LogFactory.class" => MergeStrategy.first case PathList(ps @ _*) if ps.last endsWith "SimpleLog$1.class" => MergeStrategy.first case x => old(x) } }