Enhancing Security with Manifest Attributes. 即把程序入口(含main方法的类)添加进manifest中. The Capsule plugin provides the ability to pull this config and apply it to the built capsules, thus saving you from having to enter it twice (once at the exec plugin and second at the capsule plugin). In this section, you learn how to use maven-jar-plugin to create a manifest file and package it by adding it to the JAR file. Posted on 11/04/2018 by aalmiray. mvn package exec:java Notice that the exec plugin provides a configuration where you can specify the as well as other fields such as . How many times have you found yourself in a situation where you can’t tell if the artifacts used by the application are the correct ones or not? Additional Information. Customize JAR manifest entries with Maven/Gradle. 我们在用maven构建java项目时,最常用的打包命令有mvn package、mvn install、deploy,这三个命令都可完成打jar包或war(当然也可以是其它形式的包)的功能,但这三个命令还是有区别的。下面通过分别执行这三个命令的输出结果,来分析各自所执行的maven的生命周期。 Some examples of what we can use a manifest file for include setting the entry point, setting version information and configuring the classpath. It's helpful for the jar file manifest to include the main class. This section describes how to use manifest attributes to increase the security of an applet or Java Web Start application. If we perform a "mvn clean package" to build the project's jar file and then examine the MANIFEST.MF file that is generated in the jar file at META-INF/MANIFEST.MF, we see that it contains the following: MANIFEST.MF file in generated jar file Manifest-Version: 1.0 Built-By: ${user.name} Build-Jdk: ${java.version} Created-By: Apache Maven Archiver-Version: Plexus Archiver Make the Jar executable This section describes how to seal packages within a JAR file by modifying the manifest file. The manifest is a special file in a jar located the META-INF directory and named MANIFEST.MF. Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Created-By: Apache Maven Built-By: ${user.name} Build-Jdk: ${java.version} Main-Class: fully.qualified.MainClass Class-Path: plexus-utils-1.1.jar commons-lang-2.1.jar 内容をみると、javaコマンドでアプリ実行時に直書きしなくてもいいようなつくりになっています。 mavenからのMANIFEST.MFの作成方法は下記の通りです。 基本的にpom.xmlに記載します。 When you run the command mvn package to package project into a Jar, the following meta-inf/manifest.mf file will be generated and added into the final Jar file automatically. Adds the class path of the project dependencies. The manifest file contains special meta information about files within the jar file. build后manifest文件信息 . The manifest file performs the following tasks: Defines the entry point of the project and creates an executable JAR file.