tomcat-spring 源码分析--01

立即使用

SpringApplication

.run(SimpleMVCApp.class, args);

代码入口

new SpringApplication(primarySources)

this.webApplicationType = WebApplicationType.deduceFromClasspath();

code

如何决定webApplicationType?

jar包依赖决定

1.webApplicationType

1

new SpringApplication(primarySources)

.run(args)

ConfigurableEnvironment environment = prepareEnvironment(listeners, applicationArguments);

2

code

运行中环境准备

getOrCreateEnvironment

new StandardServletEnvironment()

commandLineArgs

servletConfigInitParams

servletContextInitParams

jndiProperties

systemProperties

systemEnvironment

random

application.properties ...

@PropertySource annotations on your @Configuration classes

defaultProperties

context = createApplicationContext();

3

运行中context准备

code

prepareContext(context, environment, listeners, applicationArguments, printedBanner);

AnnotationConfigServletWebServerApplicationContext

refreshContext(context);

4

code

刷新context

onRefresh();

createWebServer();

this.webServer = factory.getWebServer(getSelfInitializer());

code

TomcatServletWebServerFactory#

getWebServer

getTomcatWebServer(tomcat);

code

601
2
6
发布时间: 2020-06-29