SpringBoot Project usage Maven pack :
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
implement mvn clean package After the order , Generating applications jar, View with compressed file ,maven Automatically generated MANIFEST.MF file :
Manifest-Version: 1.0 Implementation-Title: github-demo
Implementation-Version: 2.1-SNAPSHOT Start-Class:
com.gitlab.example.demo.DemoApplication Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/ Build-Jdk-Spec: 1.8 Spring-Boot-Version:
2.2.1.RELEASE Created-By: Maven Archiver 3.4.0 Main-Class:
org.springframework.boot.loader.JarLauncher
  Dependent jar It's also being used jar in , be located BOOT-INF/lib/ Under the directory . use java -jar You can run the app jar package .

      
In order to improve the efficiency of deployment , Need to apply jar Package and dependence jar Package separation , When there is no new dependency in the project jar Package time , Just package the application separately , Apply like this jar The size of the package will be much smaller .

      
This needs to be done maven-jar-plugin plug-in unit , Change the default packaging method ; Still need maven-dependency-plugin, Put the dependent jar Package .pom The main parts of the document are as follows :
<build> <plugins> <!-- Set up apps Main The address of the parameter start dependency lookup points to the outside lib folder --> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest>
<addClasspath>true</addClasspath> <!-- What the project depends on jar At the same level lib Under the directory -->
<classpathPrefix>lib/</classpathPrefix> </manifest> </archive> </configuration>
</plugin> <!-- set up SpringBoot The packaged plug-in does not contain any Jar Dependency package --> <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <configuration> <includes>
<include> <groupId>nothing</groupId> <artifactId>nothing</artifactId>
</include> </includes> </configuration> </plugin> <!-- Setting will lib Copy to application Jar outside -->
<plugin> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId> <executions> <execution>
<id>copy-dependencies</id> <phase>prepare-package</phase> <goals>
<goal>copy-dependencies</goal> </goals> <configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration> </execution> </executions> </plugin> </plugins> </build>
         
The purpose is to make the dependent jar Bag in target/lib Under the directory , stay MANIFEST.MF Automatically add to file Class-Path attribute , Point to the jar package :
Manifest-Version: 1.0 Implementation-Title: github-demo
Implementation-Version: 2.4-SNAPSHOT Start-Class:
com.gitlab.example.demo.DemoApplication Spring-Boot-Classes: BOOT-INF/classes/
Class-Path: lib/spring-boot-starter-web-2.2.1.RELEASE.jar lib/spring-b
oot-starter-2.2.1.RELEASE.jar lib/spring-boot-2.2.1.RELEASE.jar lib/s
pring-boot-autoconfigure-2.2.1.RELEASE.jar lib/spring-boot-starter-lo
gging-2.2.1.RELEASE.jar lib/logback-classic-1.2.3.jar lib/logback-cor
e-1.2.3.jar lib/log4j-to-slf4j-2.12.1.jar lib/log4j-api-2.12.1.jar li
b/jul-to-slf4j-1.7.29.jar lib/jakarta.annotation-api-1.3.5.jar lib/sn
akeyaml-1.25.jar lib/spring-boot-starter-json-2.2.1.RELEASE.jar lib/j
ackson-databind-2.10.0.jar lib/jackson-annotations-2.10.0.jar lib/jac
kson-core-2.10.0.jar lib/jackson-datatype-jdk8-2.10.0.jar lib/jackson
-datatype-jsr310-2.10.0.jar lib/jackson-module-parameter-names-2.10.0 .jar
lib/spring-boot-starter-tomcat-2.2.1.RELEASE.jar lib/tomcat-embe
d-core-9.0.27.jar lib/tomcat-embed-el-9.0.27.jar lib/tomcat-embed-web
socket-9.0.27.jar lib/spring-boot-starter-validation-2.2.1.RELEASE.ja r
lib/jakarta.validation-api-2.0.1.jar lib/hibernate-validator-6.0.18 .Final.jar
lib/jboss-logging-3.4.1.Final.jar lib/classmate-1.5.1.jar
lib/spring-web-5.2.1.RELEASE.jar lib/spring-beans-5.2.1.RELEASE.jar l
ib/spring-webmvc-5.2.1.RELEASE.jar lib/spring-aop-5.2.1.RELEASE.jar l
ib/spring-context-5.2.1.RELEASE.jar lib/spring-expression-5.2.1.RELEA SE.jar
lib/slf4j-api-1.7.29.jar lib/spring-core-5.2.1.RELEASE.jar lib
/spring-jcl-5.2.1.RELEASE.jar Spring-Boot-Lib: BOOT-INF/lib/ Build-Jdk-Spec:
1.8 Spring-Boot-Version: 2.2.1.RELEASE Created-By: Maven Archiver 3.4.0
Main-Class: org.springframework.boot.loader.JarLauncher
such , When typing out the application jar package , Following dependence jar Package lib When the folder is placed in the same directory , use java -jar You can run the application jar It's packed .

Technology