“没有主清单属性"使用IntelliJ IDEA创建Kotlin jar时 [英] "No main manifest attribute" when creating Kotlin jar using IntelliJ IDEA
问题描述
从我的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屋!