Previously developed Java programs because of the more dependent jar package, the start command is "Java-classpath.: Lib/*.jar The main class name", which requires specifying the CLASSPATH, the entry class name, and the existence of jar packet missing hidden dangers.
Now, with Springboot's MAVEN packaging plug-in, you can organize your dependent jar packages into a jar file.
I. Creating a MAVEN Project
A name to pick up. It's called configclient. Use the following plug-in in the Pom.xml file.
Specify MainClass, note that this mainclass is not the class of the current project, it is the main class of the program we wrote ourselves.
1 <plugin>2 <groupId>Org.springframework.boot</groupId>3 <Artifactid>Spring-boot-maven-plugin</Artifactid>4 <Configuration>5 <MainClass>Com.bonc.tool.Tool2</MainClass>6 <Layout>Zip</Layout>7 </Configuration>8 <executions>9 <Execution>Ten <Goals> One <goal>Repackage</goal> A </Goals> - </Execution> - </executions> the </plugin>
springboot Packaging Plug-inSecond, packaging
MVN Package
Iii. entering target 1. Unzip the jar file
Get three of directories:
(1) Org Application entry class, responsible for loading the check jar package
(2) Boot-inf contains two directories
Lib classes, Lib is used to store all of the dependent jar packages, classes is stored in our own development program
(3) Meta-inf contains a central file for this article MANIFEST.MF this file is read first when you start the Java program to get the main classpath.
manifest-version:1.01.5.93.2.11.8.0_131main-class: Org.springframework.boot.loader.PropertiesLauncher # Java Application Portal Class
2. Move files
If we write a program that is not packaged as a jar file, put them in boot-inf/classes
If we write a program that has been packaged as a jar file, place the jar file and all of the dependent jar packages into boot-inf/lib
3. Non-compressed packaging
BOOT-inf meta-inf org
-C indicates that create creates a new file
-V indicates that the verbose detailed information is listed
-F Specify File name
-M does not create a new MANIFEST.MF
-0 Do not compress, just organize the files together.
This 0 must be added, which means no compression. Because the internal jar package has been compressed, it is compressed again, causing the internal jar to be unreadable.
4. Run the jar package
Java-jar Configclient.jar
At this point, a runnable jar package can be used.
Java app's jar package is all-in-oneness