认识可执行JAR
其中包含
jar 描述, META-INF/MANIFEST.MF
- 构造信息
- 启动类
Manifest-Version: 1.0
Implementation-Title: file
Implementation-Version: 0.0.1-SNAPSHOT
Start-Class: com.detabes.file.FileApplication
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Build-Jdk-Spec: 1.8
Spring-Boot-Version: 2.2.5.RELEASE
Created-By: Maven Archiver 3.4.0
Implementation-Vendor: detabes
Main-Class: org.springframework.boot.loader.JarLauncher
Spring boot Loader,org/springframework/boot/loader
- 加载可执行jar,并执行
- 项目内容,BOOT-INF/classes
- 项目依赖,BOOT-INF/lib
- 数据太多有删减
```shell
+—-BOOT-INF
| +—-classes
| | | application-dev.yml
| | |
| | -—com | | -—detabes | | -—file | | | FileApplication.class
| |
| -—lib | annotations-3.0.1.jar |
+—-META-INF | | MANIFEST.MF | | spring-configuration-metadata.json | |
| -—maven | -—com.detabes | -—file | pom.properties | pom.xml |
-—org -—springframework\---boot
\---loader
| ExecutableArchiveLauncher.class
|
+---archive
| Archive$Entry.class
+---data
| RandomAccessData.class
|
+---jar
| AsciiBytes.class
| Bytes.class
| CentralDirectoryEndRecord$1.class
|
\---util
SystemPropertyUtils.class
<a name="LHKRE"></a>
## 其中不包含
- JDK
- JRE
<a name="TPwIO"></a>
# 如何找到程序的入口
- JarLauncher -> @SpringBootApplication -> FileApplication
<a name="gPDCw"></a>
## jar的启动类
- MANIFEST.MF
- Main-Class: org.springframework.boot.loader.JarLauncher
<a name="X7v5X"></a>
## 项目的主类
- @SpringBootApplication
- MANIFEST.MF
- Start-Class: com.detabes.file.FileApplication
<a name="W6MSI"></a>
# spring可直接运行的jar
- <executable>true</executable>
- 谨慎使用
- 可能一些命令无法使用
- jar -xf 等
```xml
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
</plugins>
</build>
- 启动添加自定义参数
- test.config
- test.jar test.config 同名同目录
JAVA_OPTS="-Xmx1024m -Xms1024m -Xmn384m"
- test.jar test.config 同名同目录
- test.config