认识可执行JAR

其中包含

  • jar 描述, META-INF/MANIFEST.MF

    • 构造信息
    • 启动类
      1. Manifest-Version: 1.0
      2. Implementation-Title: file
      3. Implementation-Version: 0.0.1-SNAPSHOT
      4. Start-Class: com.detabes.file.FileApplication
      5. Spring-Boot-Classes: BOOT-INF/classes/
      6. Spring-Boot-Lib: BOOT-INF/lib/
      7. Build-Jdk-Spec: 1.8
      8. Spring-Boot-Version: 2.2.5.RELEASE
      9. Created-By: Maven Archiver 3.4.0
      10. Implementation-Vendor: detabes
      11. Main-Class: org.springframework.boot.loader.JarLauncher
  • Spring boot Loader,org/springframework/boot/loader

    • 加载可执行jar,并执行
  • 项目内容,BOOT-INF/classes
  • 项目依赖,BOOT-INF/lib
  • image.png
  • 数据太多有删减 ```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
    1. \---boot
    2. \---loader
    3. | ExecutableArchiveLauncher.class
    4. |
    5. +---archive
    6. | Archive$Entry.class
    7. +---data
    8. | RandomAccessData.class
    9. |
    10. +---jar
    11. | AsciiBytes.class
    12. | Bytes.class
    13. | CentralDirectoryEndRecord$1.class
    14. |
    15. \---util
    16. SystemPropertyUtils.class
  1. <a name="LHKRE"></a>
  2. ## 其中不包含
  3. - JDK
  4. - JRE
  5. <a name="TPwIO"></a>
  6. # 如何找到程序的入口
  7. - JarLauncher -> @SpringBootApplication -> FileApplication
  8. <a name="gPDCw"></a>
  9. ## jar的启动类
  10. - MANIFEST.MF
  11. - Main-Class: org.springframework.boot.loader.JarLauncher
  12. <a name="X7v5X"></a>
  13. ## 项目的主类
  14. - @SpringBootApplication
  15. - MANIFEST.MF
  16. - Start-Class: com.detabes.file.FileApplication
  17. <a name="W6MSI"></a>
  18. # spring可直接运行的jar
  19. - <executable>true</executable>
  20. - 谨慎使用
  21. - 可能一些命令无法使用
  22. - jar -xf 等
  23. ```xml
  24. <build>
  25. <plugins>
  26. <plugin>
  27. <groupId>org.springframework.boot</groupId>
  28. <artifactId>spring-boot-maven-plugin</artifactId>
  29. <configuration>
  30. <executable>true</executable>
  31. </configuration>
  32. </plugin>
  33. </plugins>
  34. </build>
  • 启动添加自定义参数
    • test.config
      • test.jar test.config 同名同目录
        1. JAVA_OPTS="-Xmx1024m -Xms1024m -Xmn384m"