春ブーツSpringApplication.runの実行

 

SpringApplication静的実行(オブジェクトソース、文字列...引数)

- >新しい新しいSpringApplication(ソース).RUN(引数);
- > SpringApplication.initialize([]ソースのオブジェクト);
- > deduceWebEnvironment()、チェック{ "のjavax.servlet.Servlet"、「org.springframework.web.context。 ConfigurableWebApplicationContext「}ウェブ環境があれば、そこにあるか、そうでない場合は、Web環境ではありません
- > ClassUtils.isPresent(文字列クラス名、クラスローダクラスローダ); //チェッククラス、デフォルトのクラスローダがnullである
- > ClassUtils.forName(文字列名、クラスローダクラスローダ)にClassNotFoundException、のLinkageErrorがスローされます; //ロードクラス
- >それ以外の場合はそうでない場合は、配列が配列の場合、配列は、その後、再帰的に呼び出さにforName内側の名前を取るかどうかをチェックし、返されたが、そこに存在するかどうかを確認し、原子マップ、共通名クラスキャッシュを入力クラスローダは、クラスをロードする
- > getSpringFactoriesInstancesインタフェース初期ApplicationContextInitializerによってインスタンス
- > SpringFactoriesLoader.loadFactoryNames(タイプ、クラスローダ) ); ローディングの種類に応じて、読み出しFACTORIES_RESOURCE_LOCATION = "META-INF / spring.factories " "META-INF / spring.factories"と呼ばれるリソースは、多くの、ある
走査に関連するパッケージは、パッケージはApplicationContextInitializerがでようやく見つけ、とされて含まれている
ファイル:/ D:/Users/jwlv/.m2/repository/org/springframework/boot/spring-boot/1.5.16.RELEASE/spring-boot-1.5.16瓶 。 RELEASE.jar!/META-INF/spring.factoriesは、次のプロパティを見つけました

>「org.springframework.boot.diagnostics.analyzer.BeanCurrentlyInCreationFailureAnalyzer、org.springframework.boot.diagnostics.analyzer.BeanNotOfRequiredTypeFailureAnalyzer、org.springframework - "org.springframework.boot.diagnostics.FailureAnalyzer" 0 = {1897 @ $ハッシュテーブルエントリ} .boot.diagnostics.analyzer.BindFailureAnalyzer、org.springframework.boot.diagnostics.analyzer.ConnectorStartFailureAnalyzer、org.springframework.boot.diagnostics.analyzer.NoSuchMethodFailureAnalyzer、org.springframework.boot.diagnostics.analyzer.NoUniqueBeanDefinitionFailureAnalyzer、org.springframework.boot .diagnostics.analyzer.PortInUseFailureAnalyzer、org.springframework.boot.diagnostics.analyzer.ValidationExceptionFailureAnalyzer」
"org.springframework.boot.env.EnvironmentPostProcessor" 1 = {1898 @ $ハッシュテーブルエントリ} - > "org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor、org.springframework.boot.env.SpringApplicationJsonEnvironmentPostProcessor"
2 = {ハッシュテーブルエントリ$ @ 1899} "org.springframework.boot.SpringApplicationRunListener" - > "org.springframework.boot.context.event.EventPublishingRunListener"
3 = {ハッシュテーブル$エントリ1900 @} "org.springframework.context.ApplicationContextInitializer" - >「org.springframework .boot.context.ConfigurationWarningsApplicationContextInitializer、org.springframework.boot.context.ContextIdApplicationContextInitializer、org.springframework.boot.context.config.DelegatingApplicationContextInitializerは、org.springframework.boot.context.embedded。ServerPortInfoApplicationContextInitializer」
> "org.springframework.boot.env.PropertiesPropertySourceLoader、org.springframework.boot.env.YamlPropertySourceLoader" - "org.springframework.boot.env.PropertySourceLoader" 4 = {1901 @ $ハッシュテーブルエントリ}
5 = "org.springframework.context.ApplicationListener" {1902 @ $ハッシュテーブルエントリ} - >「org.springframework.boot.ClearCachesApplicationListener、org.springframework.boot.builder.ParentContextCloserApplicationListener、org.springframework.boot.context.FileEncodingApplicationListener、ORG .springframework.boot.context.config.AnsiOutputApplicationListener、org.springframework.boot.context.config.ConfigFileApplicationListener、org.springframework.boot.context.config.DelegatingApplicationListener、org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener、org.springframework.boot .logging.ClasspathLoggingApplicationListener、org.springframework.boot.logging.LoggingApplicationListener」
> "org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter" - "org.springframework.boot.diagnostics.FailureAnalysisReporter" 6 = {1903 @ $ハッシュテーブルエントリ}

加载3 = {1900 @ $ハッシュテーブルエントリ}「org.springframework.context。 ApplicationContextInitializer "中的四个类

のjar在:ファイル:/ D:/Users/jwlv/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.5.16.RELEASE/spring-boot-autoconfigure-1.5 .16.RELEASE.jar /META-INF/spring.factories!

"org.springframework.boot.autoconfigure.AutoConfigurationImportFilter" 0 = {2121 @ハッシュテーブル$エントリ} - > "org.springframework.boot.autoconfigure.condition.OnClassCondition"
"org.springframework.boot.diagnostics.FailureAnalyzer" 1 = {2122 @ $ハッシュテーブルエントリ} - >「org.springframework.boot.autoconfigure.diagnostics.analyzer.NoSuchBeanDefinitionFailureAnalyzer、org.springframework.boot.autoconfigure.jdbc.DataSourceBeanCreationFailureAnalyzer、ORG .springframework.boot.autoconfigure.jdbc.HikariDriverConfigurationFailureAnalyzer」
org.springframework.boot.autoconfigure.AutoConfigurationImportListener 2 = {2123 @ $ハッシュテーブルエントリ} "" - > "org.springframework.boot.autoconfigure.condition.ConditionEvaluationReportAutoConfigurationImportListener"
"org.springframework.context.ApplicationContextInitializer" 3 = {2124 @ $ハッシュテーブルエントリ} - > "org.springframework.boot.autoconfigure.SharedMetadataReaderFactoryContextInitializer、org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer"
4 = {ハッシュテーブルエントリ$ @ 2125} "org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider" - >「org.springframework.boot.autoconfigure.freemarker.FreeMarkerTemplateAvailabilityProvider、org.springframework.boot.autoconfigure.mustache.MustacheTemplateAvailabilityProvider、org.springframework.boot.autoconfigure。 groovy.template.GroovyTemplateAvailabilityProvider、org.springframework.boot.autoconfigure.thymeleaf.ThymeleafTemplateAvailabilityProvider、org.springframework.boot.autoconfigure.web。JspTemplateAvailabilityProvider」
> "org.springframework.boot.autoconfigure.BackgroundPreinitializer" - "org.springframework.context.ApplicationListener" 5 = {2126 @ $ハッシュテーブルエントリ}
>「org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration、org.springframework.boot.autoconfigure.aop.AopAutoConfiguration、org.springframework - "org.springframework.boot.autoconfigure.EnableAutoConfiguration" 6 = {2127 @ $ハッシュテーブルエントリ} .boot.autoconfigure.amqp.RabbitAutoConfiguration、org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration、org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration、org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration、org.springframework.boot .autoconfigure.cloud.CloudAutoConfiguration、org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration、org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration、org.springframework.boot.autoconfigure.context。PropertyPlaceholderAutoConfiguration、org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration、org.springframework.boot.autoconfigure.dao.PersistenceExceptionTranslationAutoConfiguration、org.springfra

"org.springframework.context.ApplicationContextInitializer"加载3 = {2124 @ $ハッシュテーブルエントリ}的两个类中

最终名、需要类返回下面6个被初始化
0 = "org.springframework.boot.context.ConfigurationWarningsApplicationContextInitializer"
1 = "org.springframework.boot.context.ContextIdApplicationContextInitializer"
2 = "org.springframework.boot.context.config.DelegatingApplicationContextInitializer"
3 = "org.springframework.boot.context.embedded.ServerPortInfoApplicationContextInitializer"
4 =「org.springframework.boot。 autoconfigure.SharedMetadataReaderFactoryContextInitializer」
5 = "org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer"
- >クラス名返されるコレクション上記createSpringFactoriesInstancesは、現在SpringApplication.initializersをインスタンス化されます

- >例ApplicationListener SpringApplication.listenersの存在下で最後のインスタンス化されたリスナーの界面の初期化、同様に実施例イニシャライザの方法、
0 =「org.springframework.boot.ClearCachesApplicationListener」
1 =「org.springframework.boot.builder.ParentContextCloserApplicationListener。 "
2 =" org.springframework.boot.context.FileEncodingApplicationListener "
3 =" org.springframework.boot.context.config.AnsiOutputApplicationListener "
4 =" org.springframework.boot.context.config.ConfigFileApplicationListener "
5 =" org.springframework .boot.context.config.DelegatingApplicationListener
"6 =" org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener "
7 =" org.springframework.boot.logging。ClasspathLoggingApplicationListener」
= 8 "org.springframework.boot.logging.LoggingApplicationListener"
9 = "org.springframework.boot.autoconfigure.BackgroundPreinitializer"。

- > deduceMainApplicationClassは()を見つけるために、新規のRuntimeException()getStackTraceメソッドを()リストスタックフレームを取得することにより、メインクラスを推測。主な方法。

- > SpringApplication.run(文字列...引数)
- >例getSpringFactoriesInstances初期化SpringApplicationRunListenerインタフェース(org.springframework.boot.context.event.EventPublishingRunListener)と開始、によって
初期化環境情報新しいStandardServletEnvironment()は、

バナーの処理を、開始しますスクリーン、

インスタンスのコンテキストはorg.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContextを、インスタンス化に係るWeb環境をConfigurableApplicationContext
org.springframework.context.annotation.AnnotationConfigApplicationContext、記載又はインスタンス化

初期化FailureAnalyzers、分析のために、

前述の初期化上の行のテキストprepareContext(ConfigurableApplicationContextコンテキスト、ConfigurableEnvironment環境、用意した構成情報 SpringApplicationRunListenersリスナーを、
context.setEnvironment(環境)のApplicationContext、MessageSource、LifecycleProcessor、ApplicationEventMulticaster、初期化請求ApplicationArguments applicationArguments、バナーprintedBanner)、
ResourcePatternResolver、BeanFactoryPostProcessor、applicationListeners、ConfigurableListableBeanFactory
、初期化子のコンテキストでapplyInitializers(コンテキスト)
context.getBeanFactory()。RegisterSingleton( "豆の特別な一の実施形態では、ロードspringApplicationArguments」、applicationArguments)スプリング
BeanDefinitionLoaderの例として、源を含む、annotatedReader、XMLReaderの、スキャナ、 groovyReader ローディングの様々なタイプを実行するように構成された構成の様々なタイプを読み取るための属性、
SpringBootServletInitializerの初期化のためにロードしますサブクラスの設定。

コンテキストパラメータの更新は、基礎となる一般的な初期化コンテキストの一部豆、OnRefresh AbstractApplicationContext()メソッドの呼び出し、及び、その後)(createEmbeddedServletContainerによってコンテナを作成し、refreshContext(コンテキスト)を調製し、そして
どのtomcatEmbeddedServletContainerFactoryを使用されます。
豆初期化時間は、例えば、すべての最初の豆A、初期化時間を有するようmergedBean概念が存在するであろう、親は、親がAとmergedBean Bにマージされないチェックがない場合、プロセス前まで、再帰的にbは、単一の実施形態も何ら依存性、プロセスは、他の属性を初期化しません
豆の一つの実施形態において豆(b)に非単を含む場合、それは単一のケースではありません。
最後に、onRefreshで()Tomcatを開始します。
次いでfinishBeanFactoryInitialization(たBeanFactory)メソッドは、Beanの他の非遅延-INITを初期化し、Bean名は、最初のように、登録のリスト横断する
戻りコンテキスト。






















おすすめ

転載: www.cnblogs.com/lvjianwei/p/11225895.html