可运行jar文件中的启动清单文件 META-INF/MANIFEST.MF 内容自定义生成
清单文件中的 Main-Class: Premain-Class: Can-Retransform-Classes: 在maven-assembly-plugin插件中的生成配置如下, 注意命名
<archive>
<manifest>
<mainClass>cn.tekin.burploaderkeygen.KeygenForm</mainClass>
</manifest>
<manifestEntries>
<Premain-Class >cn.tekin.burploaderkeygen.Loader</Premain-Class>
<Can-Retransform-Classes>true</Can-Retransform-Classes>
</manifestEntries>
</archive>
打包jar文件夹后生成的清单如下:
Main-Class: cn.tekin.burploaderkeygen.KeygenForm
Can-Retransform-Classes: true
Premain-Class: cn.tekin.burploaderkeygen.Loader
maven pom.xml 完整配置文件如下
XML
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.tekin</groupId>
<artifactId>burploaderkeygen</artifactId>
<version>1.18</version>
<properties>
<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<finalName>burploaderkeygen-v${version}</finalName>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>cn.tekin.burploaderkeygen.KeygenForm</mainClass>
</manifest>
<manifestEntries>
<Premain-Class>cn.tekin.burploaderkeygen.Loader</Premain-Class>
<Can-Retransform-Classes>true</Can-Retransform-Classes>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
总结:
从上面可以得出 主入口类的定义在manifest节点,且命名为小驼峰(配置 mainClass 最后生成 Main-Class ), 其他的清单配置都定义在manifestEntries节点,命名方式为首字母大写加连接线-的方式