最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Spring Boot啟動(dòng)流程斷點(diǎn)過程解析

 更新時(shí)間:2019年11月27日 10:40:37   投稿:yaominghui  
這篇文章主要介紹了Spring Boot啟動(dòng)流程斷點(diǎn)過程解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

這篇文章主要介紹了Spring Boot啟動(dòng)流程斷點(diǎn)過程解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

啟動(dòng)入口

跟進(jìn)run方法 : 一個(gè)用來(lái)使用默認(rèn)的配置從特定的源運(yùn)行SpringApplication的靜態(tài)幫助類。

這個(gè)類有兩個(gè)重載方法,另一個(gè)用來(lái)傳入多個(gè)源。通常,單個(gè)參數(shù)方法是數(shù)組方法的一個(gè)特例

創(chuàng)建一個(gè)新的SpringApplication實(shí)例。這個(gè)應(yīng)用程序上下文會(huì)從特定的源加載Beans,這個(gè)實(shí)例會(huì)在調(diào)用run方法之前被定制化。

Web應(yīng)用程序類型的枚舉:WebApplicationType,包含NONE(不是web應(yīng)用),SERVLET(基于Servlet的web應(yīng)用),REACTIVE(基于Reactive的web應(yīng)用)

  • 直接jar包運(yùn)行不使用web容器
  • 使用嵌入式的Servlet web容器
  • 使用反應(yīng)式的web容器

setInitializers((Collection) getSpringFactoriesInstances(
  ApplicationContextInitializer.class));

用于創(chuàng)建和加載Spring工廠方法實(shí)例

4.運(yùn)行SpringApplication的run方法

Java SPI在 Spring Boot中的應(yīng)用

SpringBoot底層的自動(dòng)化都是由這些SPI實(shí)現(xiàn)類來(lái)實(shí)現(xiàn)的:初始化,監(jiān)聽器,自動(dòng)配置導(dǎo)入監(jiān)聽器,自動(dòng)配置導(dǎo)入過濾器,自動(dòng)配置,失敗分析器,可用模板提供者

Spring Boot找到main方式的方式

通過拋異常的形式來(lái)獲取堆棧信息,再獲取啟動(dòng)類的信息。

以上都是new SpringBootApplication的過程,下面分析run方法

/**
* Run the Spring application, creating and refreshing a new
* {@link ApplicationContext}.
* 運(yùn)行一個(gè)Spring應(yīng)用,創(chuàng)建和刷新一個(gè)新的ApplicationContext
* @param args the application arguments (usually passed from a Java main method)
* 應(yīng)用參數(shù)通過java main方法傳遞過來(lái)
* @return a running {@link ApplicationContext}
*/
public ConfigurableApplicationContext run(String... args) {
// 任務(wù)計(jì)時(shí)器工具,可同時(shí)計(jì)數(shù)多個(gè)任務(wù)
StopWatch stopWatch = new StopWatch();
stopWatch.start();
//ApplicationContext是Spring的中心接口,為應(yīng)用提供配置:1bean工廠2加載資源3注冊(cè)的監(jiān)聽器發(fā)布事件4解析消息
ConfigurableApplicationContext context = null;
Collection<SpringBootExceptionReporter> exceptionReporters = new ArrayList<>();
//headless 模式:服務(wù)器端模式,表示系統(tǒng)沒有鍵盤鼠標(biāo)等前端應(yīng)用
configureHeadlessProperty();
//監(jiān)聽器容器,對(duì)run方法各個(gè)階段事件進(jìn)行監(jiān)聽,觀察者模式
SpringApplicationRunListeners listeners = getRunListeners(args);
//監(jiān)聽相應(yīng)的事件,SpringApplicationEvent下的一個(gè)實(shí)現(xiàn)
listeners.starting();
try {
//提供了對(duì)于運(yùn)行SpringApplication參數(shù)的訪問
ApplicationArguments applicationArguments = new DefaultApplicationArguments(
args);
//環(huán)境配置:是servlet,reactive或者java應(yīng)用環(huán)境,觸發(fā)evn準(zhǔn)備好的事件
ConfigurableEnvironment environment = prepareEnvironment(listeners,
applicationArguments);
configureIgnoreBeanInfo(environment);
Banner printedBanner = printBanner(environment);
context = createApplicationContext();
exceptionReporters = getSpringFactoriesInstances(
SpringBootExceptionReporter.class,
new Class[] { ConfigurableApplicationContext.class }, context);
prepareContext(context, environment, listeners, applicationArguments,
printedBanner);
refreshContext(context);
afterRefresh(context, applicationArguments);
stopWatch.stop();
if (this.logStartupInfo) {
new StartupInfoLogger(this.mainApplicationClass)
.logStarted(getApplicationLog(), stopWatch);
}
listeners.started(context);
callRunners(context, applicationArguments);
}
catch (Throwable ex) {
handleRunFailure(context, ex, exceptionReporters, listeners);
throw new IllegalStateException(ex);
}

try {
listeners.running(context);
}
catch (Throwable ex) {
handleRunFailure(context, ex, exceptionReporters, null);
throw new IllegalStateException(ex);
}
return context;
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

海兴县| 永寿县| 锡林郭勒盟| 五大连池市| 肥东县| 黄大仙区| 沧州市| 肇东市| 文成县| 修武县| 白玉县| 新乡县| 梓潼县| 东平县| 广水市| 天镇县| 淅川县| 资中县| 东平县| 黑龙江省| 景德镇市| 永兴县| 东明县| 宁远县| 辉南县| 米泉市| 若羌县| 化隆| 阿拉尔市| 东城区| 项城市| 嵊州市| 丹凤县| 南部县| 基隆市| 上饶市| 海林市| 鲁山县| 五指山市| 安仁县| 孟州市|