且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

打包和部署 Scala 应用程序

更新时间:2021-09-29 03:08:59

打包 Scala 应用程序最简单(也是最一致)的方法是打包到 JAR 中(就像使用普通 Java 应用程序一样).只要 JAR 由标准编译的 Java 类组成,您就可以运行Scala"JAR,即使您的机器上没有 Scala 运行时(您所需要的只是类路径中的 Java 运行时和 scala-lang.jar).您可以在清单中指定主类(应用程序功能的网关)

The simplest (and the most consistent) way to package a Scala application, is packaging into a JAR (like you do with normal Java applications). As long as JAR consists of standard compiled Java classes, you may run "Scala" JAR, even if you don't have Scala runtime at the box (all you need is a Java Runtime and scala-lang.jar on the classpath). You may specify the main class (gateway to functionalities of your application) in the manifast

Main-Class: mypackage.MyClass

这样您就可以调用它,只需将 JAR 名称传递给 java.exe.

so that you'll be able to call it only passing a JAR name to java.exe.

java -jar myjar.jar

您可以在指定主类SBT 项目定义.

You may specify the main class in SBT project definition.