Spring Boot 原始碼分析

2021-10-24 04:45:36 字數 788 閱讀 7114

1、專案初始化過程

springboot啟動類

springboot的啟動很簡單,**如下:

public static void main(string args)

}this.resourceloader = resourceloader;

initialize(sources); }

private void initialize(object sources)

this.webenvironment = deducewebenvironment();

//springfactoriesloader:工廠載入機制

setinitializers((collection) getspringfactoriesinstances(

//從當前呼叫棧中,查詢主類 }

1.2、run 方法

啟動run過程

//stopwatch 用於簡單監聽run啟動過程

stopwatch stopwatch = new stopwatch();

stopwatch.start();

failureanalyzers analyzers = null;

configureheadlessproperty();

listeners.started();

try

return context;

} catch (throwable ex)

}

SpringBoot原始碼分析

public class 第乙個引數 resourceloader 資源載入器 第二個引數 primarysources 載入的主要資源類 suppresswarnings public resourceloader resourceloader,class primarysources deduc...

spring boot原始碼分析

spring boot關鍵流程分析 進入preparecontext方法 轉化成beandefiniton類,註冊到spring 的beandefintionmap容器 enableautoconfigurationimportselector類,其父類裡面 這裡利用spring的功能,動態載入配置...

原始碼分析SpringBoot啟動

none,不是web專案 servlet,是web專案 reactive 之後新加的,響應式專案 private collectiongetspringfactoriesinstances classtype,class parametertypes,object.args 首先得到classloa...