Write this blog mainly for their own later can quickly find.
Add the following build content to the project node of the Pom.xml file:
<build> <plugins> <plugin> <groupid>org.apache.maven.plugi Ns</groupid> <artifactId>maven-jar-plugin</artifactId> <version>2. 3.2</version> <configuration> <archive> <
manifest> <!--change Addclasspath to True if Daks is desktop version--> <addClasspath>true</addClasspath> <classpathprefix>lib/</c
Lasspathprefix> <mainClass>com.daks.timesheethelper.App</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries> <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> </mani
Fest> <manifestEntries> <Permissions>${Permissions}</Permissions>
<Caller-Allowable-Codebase>${Caller-Allowable-Codebase}</Caller-Allowable-Codebase>
</manifestEntries> </archive> </configuration> </plugin> <plugin> <GROUPID>ORG.APACHE.MAVEN.PLUGINS</GROUPID&G
T
<artifactId>maven-dependency-plugin</artifactId> <version>2.3</version> <executions> <execution> <id>copy-dependencies</id&
Gt <phase>package</phase> <configuration> <overwrite Releases>false</overwritereleases> <overwritesnapshots>fAlse</overwritesnapshots> <overWriteIfNewer>true</overWriteIfNewer>
<outputDirectory> ${project.build.directory}/lib
</outputDirectory> </configuration> <goals>
<goal>copy-dependencies</goal> </goals> </execution> </executions> </plugin> </plugins> & Lt;/build>
The end result is a Lib directory under target that contains some third-party jars that the project uses, or a jar of its own other projects, and then Main-class and Class-path configuration information in the MF file of the main jar package. This is the condition that guarantees that the jar package is executable.
See also: http://www.alanzeng.cn/2015/08/maven-executive-jar/