scala sbt 程序集“没有主要清单属性"; [英] scala sbt assembly "no main manifest attribute"

查看:45
本文介绍了scala sbt 程序集“没有主要清单属性";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 sbt 中使用组装插件来组装我的项目.但是通过java -jar xx.jar"运行时会发生错误 -

I use assembly plugin in sbt to assemble my project. But errors happen when run by "java -jar xx.jar" -

没有主要清单属性".

我认为这是因为我的 src/main/scala/ 目录中有两个文件,每个文件都有一个扩展 Application 的对象,这意味着在项目.但是我需要两个应用程序,一个是服务器,另一个是测试客户端.

I think it's because there are two files in my src/main/scala/ directory and each with an object extending Application which means there are two main entry in the project. But I need two applications, one is the server and the other is the test client.

如何在scala sbt 中处理这个two-main-entry 问题.提前致谢.

How to handle this two-main-entry problem in scala sbt. Thanks in advance.

推荐答案

在您的 SBT 构建文件中,定义主类.

In your SBT build file, define the main class.

如果您使用的是 build.sbt,则为:

If you are using build.sbt, then that would be:

mainClass in assembly := Some("com.domain.Main")

如果您使用的是 Build.scala,那么您可以执行以下操作:

If you are using Build.scala then you could do something like:

lazy val app = (project in file("app")).
  settings(assemblySettings: _*)
  settings(mainClass in assembly := Some("com.domain.Main"))

这篇关于scala sbt 程序集“没有主要清单属性";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆