“没有主清单属性"使用IntelliJ IDEA创建Kotlin jar时 [英] "No main manifest attribute" when creating Kotlin jar using IntelliJ IDEA

查看:660
本文介绍了“没有主清单属性"使用IntelliJ IDEA创建Kotlin jar时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我的Kotlin代码创建一个jar并运行它时,它显示无主清单属性". 当查看manifest.mf时,它具有以下内容:

When creating a jar from my Kotlin code and running it, it says "No main manifest attribute". When looking at the manifest.mf, it has this content:

Manifest-Version: 1.0

在源文件中查看文件时,它具有以下内容:

When looking at the file in the source, it has this content:

Manifest-Version: 1.0
Main-Class: MyMainClass

当手动将源清单复制到jar时,它可以完美运行.

When manually copying the source manifest to the jar, it runs perfectly.

我的工件设置的屏幕截图

推荐答案

如果任何相关的jar都具有MANIFEST.MF文件,它将覆盖定义Main-Class的自定义文件.

If any of the dependent jars has a MANIFEST.MF file, it will override your custom one which defines the Main-Class.

为了解决此问题,您应该执行以下操作:

In order to address this problem you should do the following:

  • Disable the alphabetical ordering
  • Change items ordering so that item which has META-INF/MANIFEST.MF file is the first in the list
  • Your custom MANIFEST.MF will be picked up by IntelliJ IDEA and displayed for the jar artifact.

有关更多详细信息,请参见相关问题.

See the related issue for more details.

您也可以改用Gradle或Maven来生成胖子.

You can also use Gradle or Maven to generate the fat jar instead.

这篇关于“没有主清单属性"使用IntelliJ IDEA创建Kotlin jar时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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