1.首先在 project/plugins.sbt: 下加入这段代码:
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
import AssemblyKeys._ // put this at the top of the fileassemblySettings// your assembly settings here
之后就可以sbt assembly
来打包了,生成./target/scala_x.x.x/projectname-assembly-x.x.x.jar
在assembly.sbt内写入:
import AssemblyKeys._assemblySettingsjarName 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)}}