简体   繁体   English

SBT 编译 uber jar

[英]SBT Compile for uber jar

What is the best way to make a SBT project work in offline environment?使 SBT 项目在离线环境中工作的最佳方法是什么? There is any ways to compile it outside (in network env), eg uber jar with all its dependencies, and then in the offline env just run it?有什么方法可以在外部(在网络环境中)编译它,例如 uber jar 及其所有依赖项,然后在离线环境中运行它?

For example in Java Maven, We can compile it with uber jar with all dependencies, and then in the offline env just java -jar MyJar.jar ...例如在 Java Maven 中,我们可以使用包含所有依赖项的 uber jar 编译它,然后在离线 env 中只需java -jar MyJar.jar ...

Thanks.谢谢。

Best bet for creating an uber/fat jar is the sbt assembly plugin .创建 uber/fat jar 的最佳选择是sbt assembly plugin Include it in your project by putting something like the following in project/assembly.sbt通过在project/assembly.sbt放置类似以下内容的内容,将其包含在您的项目中

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")

Then just running sbt assembly should create a jar with all the dependencies in target/scala_$SCALA_VERSION .然后只运行sbt assembly应该创建一个包含target/scala_$SCALA_VERSION所有依赖项的 jar。 You may need to designate a main class for the jar if you want to run it with java -jar (as opposed to java -cp $jarfile $mainclass ):如果要使用java -jar运行它,则可能需要为 jar 指定一个主类(而不是java -cp $jarfile $mainclass ):

mainClass in assembly := Some("package.mainClass")

暂无
暂无

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

相关问题 Uber jar 带有 IntelliJ 和 SBT 的自定义文件夹结构 - Uber jar with custom folder structure with IntelliJ and SBT 在 uber jar 中构建 sbt 项目而不是单独的子模块 jar - Build sbt project in uber jar instead of individual submodule jars Spark Standalone:如何避免 sbt 组件和 uber-jar? - Spark Standalone : how to avoid sbt assembly and uber-jar? 不包括优步(胖)罐子在玩! 在斯卡拉 - excluding from Uber (fat) jar in sbt for Play! in Scala 使用sbt-assembly在SBT中的uber-jar创建中的文件冲突 - Conflicting files in uber-jar creation in SBT using sbt-assembly 如何在sbt中编译多个不同的jar文件 - how to compile multiple different jar files in sbt 使用SBT或gradle将scala编译为装配罐 - compile scala to assembly jar with SBT or gradle 如何在 IntelliJ IDEA 中使用 SBT 构建 Uber JAR(Fat JAR)? - How to build an Uber JAR (Fat JAR) using SBT within IntelliJ IDEA? 为什么 Spark 应用程序会以“ClassNotFoundException: Failed to find data source: kafka”作为带有 sbt 程序集的 uber-jar 失败? - Why does Spark application fail with “ClassNotFoundException: Failed to find data source: kafka” as uber-jar with sbt assembly? 为什么Spark应用程序因“ClassNotFoundException:无法找到数据源:jdbc”而失败,因为uber-jar与sbt程序集一起? - Why does Spark application fail with “ClassNotFoundException: Failed to find data source: jdbc” as uber-jar with sbt assembly?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM