diff --git a/README.md b/README.md index 3768ff02..3d67fe1e 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ * [《芋道 Spring Boot 快速入门》](http://www.iocoder.cn/Spring-Boot/quick-start/?github) * [《芋道 Spring Boot 自动配置原理》](http://www.iocoder.cn/Spring-Boot/autoconfigure/?github) 对应 [lab-47](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-47) +* [《芋道 Spring Boot 芋道 Spring Boot Jar 启动原理》](http://www.iocoder.cn/Spring-Boot/jar/?github) ## 开发工具 diff --git a/lab-39/lab-39-demo/pom.xml b/lab-39/lab-39-demo/pom.xml index 199ba33d..b0bec084 100644 --- a/lab-39/lab-39-demo/pom.xml +++ b/lab-39/lab-39-demo/pom.xml @@ -18,6 +18,10 @@ org.springframework.boot spring-boot-starter-web + + + + diff --git a/lab-39/lab-39-demo/src/main/java/cn/iocoder/springboot/lab39/skywalkingdemo/Application.java b/lab-39/lab-39-demo/src/main/java/cn/iocoder/springboot/lab39/skywalkingdemo/Application.java index 62665a61..6bf7234d 100644 --- a/lab-39/lab-39-demo/src/main/java/cn/iocoder/springboot/lab39/skywalkingdemo/Application.java +++ b/lab-39/lab-39-demo/src/main/java/cn/iocoder/springboot/lab39/skywalkingdemo/Application.java @@ -3,10 +3,47 @@ package cn.iocoder.springboot.lab39.skywalkingdemo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import java.io.IOException; +import java.net.URISyntaxException; + @SpringBootApplication public class Application { - public static void main(String[] args) { + public static void main(String[] args) throws URISyntaxException, IOException { +// ProtectionDomain protectionDomain = Launcher.class.getProtectionDomain(); +// CodeSource codeSource = protectionDomain.getCodeSource(); +// URI location = (codeSource != null) ? codeSource.getLocation().toURI() : null; +// String path = (location != null) ? location.getSchemeSpecificPart() : null; +// if (path == null) { +// throw new IllegalStateException("Unable to determine code source archive"); +// } +// File root = new File(path); +// System.out.println(root + "" + root.isDirectory()); +// // 创建 Archive 对象 +// Archive archive = new JarFileArchive(root); +// // 创建 EntryFilter 对象 +// Archive.EntryFilter filter = new Archive.EntryFilter() { +// +// static final String BOOT_INF_CLASSES = "BOOT-INF/classes/"; +// +// static final String BOOT_INF_LIB = "BOOT-INF/lib/"; +// +// @Override +// public boolean matches(Archive.Entry entry) { +// // 如果是目录的情况,只要 BOOT-INF/classes/ 目录 +// if (entry.isDirectory()) { +// return entry.getName().equals(BOOT_INF_CLASSES); +// } +// // 如果是文件的情况,只要 BOOT-INF/lib/ 目录下的 `jar` 包 +// return entry.getName().startsWith(BOOT_INF_LIB); +// } +// +// }; +// // 执行读取 +// for (Archive item : archive.getNestedArchives(filter)) { +// System.out.println(item.getUrl()); +// } + SpringApplication.run(Application.class, args); } diff --git a/pom.xml b/pom.xml index f94b8e36..71acae86 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ - + lab-22