當前位置:成語大全網 - 書法字典 - Springboot知識集成

Springboot知識集成

在我看來,springboot最大的好處就是簡化配置。以前壹個SpringMvc項目需要用xml配置各種東西,現在簡化了很多配置,提高了開發效率。

壹般我的啟動類都會有@SpringBootApplication註釋,這是壹個組合註釋。

這裏更重要的是@EnableAutoConfiguration。

@Import是Spring提供的,會註入到後面的類auto configuration Import selector中。

其中方法調用是選擇導入-& gt;getAutoConfigurationEntry-& gt;getCandidateConfigurations

往裏看,妳會在meta-INF/spring中得到所需的類型。因素文件。

獲取該類的方法將被稱為abstractapplicationcontext。springboot開始時刷新()。

以tomcat為例,看看springboot的啟動和加載過程。

我們通常運行主方法SpringApplication.run

我們來看看SpringApplication的構造方法。

接下來主要看跳羚的跑法。

我們主要看refreshContext方法,它會調用父類AbstractApplicationContext的refresh方法,它會調用子類的onRefresh方法,這是壹個模板方法模式。接下來看看。

createWebServer方法將創建壹個web容器,然後您可以看到創建tomcat的代碼。

/s/ax RIA 4kh 1 Yus VI 3 wcofwpg

/s/tnvl 1 chwtqlxmlodcujcsg

/s/y6 putkrcucoegmgqwrdow