mirror of
https://gitee.com/yudaocode/SpringBoot-Labs.git
synced 2026-09-03 05:53:54 +08:00
增加 spring boot jar 启动原理
This commit is contained in:
@@ -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)
|
||||
|
||||
## 开发工具
|
||||
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-loader</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user