jar 清单是否支持 `Class-Path`?为什么要改用 spring-boot-loader?

Does jar manifest support `Class-Path`? Why use spring-boot-loader instead?

我知道 spring 引导使用 spring-boot-loader 打包一个可执行 jar,并使用 class 从 BOOT-INF/lib 加载其他 jar,如 this post 中所述名为 JarLauncher.

看完this post,我在想Class-Path in manifest也可以做到这一点

那么为什么 spring boot 做这么多工作来从自定义 BOOT-INF/lib 加载 jar,而不是简单地写在 META-INF/MANIFEST.MF:

Class-Path: BOOT-INF/lib

Class-Path 清单方法不支持从嵌套在 jar 中的 jar 文件加载 类。从您在问题中链接到的 Oracle 文档:

The Class-Path header points to classes or JAR files on the local network, not JAR files within the JAR file or classes accessible over Internet protocols. To load classes in JAR files within a JAR file into the class path, you must write custom code to load those classes. For example, if MyJar.jar contains another JAR file called MyUtils.jar, you cannot use the Class-Path header in MyJar.jar's manifest to load classes in MyUtils.jar into the class path.

Spring Boot 的 JarLauncherspring-boot-loader 中的其他 类 是允许 类 从嵌套在 jar 中的 jars 加载的自定义代码.