1 Executable JAR files
2 Define a main class in your JAR's MANIFEST.MF file that defines the executable class. (MANIFEST.MF is the file that Maven generates when packaging your application.)
3 Find all of the libraries on which your project depends.
4 Include those libraries in your MANIFEST.MF file so that your application classes can find them.
MANIFEST.MF is the file that Maven generates when packaging your application.
举例:
MANIFEST.MF
Manifest-Version: 1.0
Premain-Class: com.geekcap.openapm.jvm.agent.Agent
Can-Redefine-Classes: true
Can-Retransform-Classes: true
Can-Set-Native-Method-Prefix: true
src/main/resources/META-INF/MANIFEST.MF
com.geekcap.openapm.ui.PerformanceAnalyzer
This is an interesting example because it both defines a Premain-Class that allows the JAR file to work as a Java agent and has a mainClass that allows it to run as an executable JAR file. In this particular example, I've used OpenAPM (a code tracing tool that I built) to define code tracing that will be recorded by the Java agent and a user interface, which will facilitate analysis of recorded traces. In short, the example shows the power of combining an explicit manifest file with dynamic modifications.
5 springboot 的Manifest
Manifest-Version: 1.0
Implementation-Title: myproject
Implementation-Version: 0.0.1-SNAPSHOT
Built-By: jenkins
Implementation-Vendor-Id: com.myproject
Spring-Boot-Version: 2.0.6.RELEASE
Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: com.myproject.VApplication
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Created-By: Apache Maven 3.5.2
Build-Jdk: 1.8.0_151
Implementation-URL: https://projects.spring.io/spring-boot/#/spring-bo
ot-starter-parent/myproject
6 依赖树
mvn dependency:tree
7 环境选择
address/target/addressservice.war
mvn -Pdev clean install
8 自定义maven插件:
https://www.ibm.com/developerworks/java/library/j-5things13/index.html?ca=drs-