在 src/main/resources 文件夹下创建 MANIFEST.MF 文件,文件内容如下所示:
Created-By: 范丰平 Manifest-Version: 1.0 Premain-Class: org.fanfengping.agent.demo.monitor.MonitorAgent Can-Redefine-Classes: true
在项目工程 pom.xml 文件中,添加如下所示的配置信息:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.2.2</version> <configuration> <archive> <manifestEntries> <build-time>${maven.build.timestamp}</build-time> </manifestEntries> <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile> </archive> </configuration> </plugin> </plugins> </build>
通过 manifestFile 指定自定义的 MANIFEST.MF 文件
再次执行 mvn clean package 即可正确配置,覆盖原有默认的文件,文件内容如下所示: