何时使用“sbt assembly"?和 "sbt 编译 &&sbt 包"? [英] When to use "sbt assembly" and "sbt compile && sbt package"?
问题描述
我想知道什么时候应该使用 sbt assembly
以及什么时候应该使用 sbt compile &&sbt 包
?
I would like to know when should I use sbt assembly
and when sbt compile && sbt package
?
我正在使用 Intellij IDEA 在我的本地计算机上编写一个程序,并且我正在使用 sbt compile && 编译它sbt 包
,然后我将它上传到集群并使用spark-submit
运行它.这是最好的方法吗?什么时候应该使用 sbt 汇编
?
I'm coding a program in my local computer using Intellij IDEA and I'm compiling it with sbt compile && sbt package
, then I'm going to upload it to a cluster and run it using spark-submit
. Is this the best way? When should I use sbt assembly
?
推荐答案
我想知道什么时候应该使用
sbt assembly
以及什么时候应该使用sbt compile &&sbt 包
?
I would like to know when should I use
sbt assembly
and whensbt compile && sbt package
?
引用 sbt-assembly 的网站(提供 sbt assembly
):
Quoting sbt-assembly's website (which gives sbt assembly
):
目标很简单:创建一个包含所有依赖项的项目的胖 JAR.
The goal is simple: Create a fat JAR of your project with all of its dependencies.
build.sbt
中的任何依赖项(未标记为 Provided
)都将成为称为 uber-jar 的最终 jar 文件的一部分.
Any dependency in build.sbt
(that is not marked as Provided
) is going to be part of the final jar file that is called an uber-jar.
您想使用该插件至少有两个原因:
There are at least two reasons why you'd like to use the plugin:
- 将所有依赖项捆绑在一个 jar 文件中,这样更容易部署到生产环境(类似于 Docker 映像)
- 使用一个 Spark 版本(例如 2.0.0)运行您的应用程序,并使用具有来自 Spark 1.6.0 的
spark-submit
的集群
你使用 sbt compile &&sbt package
来编译和打包应用程序的类(顺便说一句,它不必使用 Spark).该 jar 文件不包含应用程序的依赖项,因此必须以其他方式提供任何依赖项(并使部署变得有点棘手).
You use sbt compile && sbt package
to compile and package the classes of your application (which by the way does not have to use Spark whatsoever). That jar file does not include the dependencies of your application so any dependencies have to be provided in some other way (and makes deployment a bit tricker).
注意:sbt 编译 &&sbt package
只是 sbt compile package
的一个较长变体,因为 compile
任务是 package
的依赖项只是 >sbt 包
.
NB: sbt compile && sbt package
is just a longer variant of sbt compile package
which given that compile
task is a dependency of package
is just sbt package
.
这篇关于何时使用“sbt assembly"?和 "sbt 编译 &&sbt 包"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!