---
title: "从日志看Spring启动过程"
author: "ch_space"
date: "2011-03-02T15:16:19Z"
tags: []
categories: ["企业架构"]
slug: "spring"
draft: false
lastmod: "2011-03-02T15:17:18Z"
id: 938330
url: "https://ch-space.iteye.com/blog/938330"
---

```java

信息: Initializing Spring root WebApplicationContext
15:07:33,078  INFO ContextLoader:189 - Root WebApplicationContext: initialization started
15:07:33,109  INFO XmlWebApplicationContext:411 - Refreshing org.springframework.web.context.support.XmlWebApplicationContext@18c56d: display name [root webapplicationcontext]; startup date [wed mar 02 15:07:33 cst 2011]; root of context hierarchy
15:07:33,156  INFO XmlBeanDefinitionReader:323 - Loading XML bean definitions from ServletContext resource [/web-inf/beans.xml]
15:07:33,390  INFO XmlBeanDefinitionReader:323 - Loading XML bean definitions from ServletContext resource [/web-inf/mail.xml]
15:07:33,406  INFO XmlWebApplicationContext:426 - Bean factory for application context [org.springframework.web.context.support.xmlwebapplicationcontext@18c56d]: org.springframework.beans.factory.support.DefaultListableBeanFactory@15fc40c
15:07:33,500  INFO PropertyPlaceholderConfigurer:178 - Loading properties file from ServletContext resource [/web-inf/jdbc.properties]
15:07:33,500  INFO PropertyPlaceholderConfigurer:178 - Loading properties file from ServletContext resource [/web-inf/mail.properties]
15:07:33,562  INFO DefaultListableBeanFactory:414 - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@15fc40c: defining beans [favoritedao,messagedao,refcommentdao,referencedao,refrequestdao,sequencedao,userdao,daosupport,facade,mailfactory,mailtask,mailtaskfactory,org.springframework.context.annotation.internalcommonannotationprocessor,org.springframework.context.annotation.internalautowiredannotationprocessor,org.springframework.context.annotation.internalrequiredannotationprocessor,org.springframework.aop.config.internalautoproxycreator,org.springframework.transaction.annotation.annotationtransactionattributesource#0,org.springframework.transaction.interceptor.transactioninterceptor#0,org.springframework.transaction.config.internaltransactionadvisor,datasource,txmanager,sqlmapclient,sqlmapclienttmp,threadpool,cookiefilter,propertyconfigurer,mailsender,regmail,updatemail]; root of factory hierarchy
15:07:33,953  INFO ThreadPoolTaskExecutor:250 - Initializing ThreadPoolExecutor 'threadPool'
15:07:33,984  INFO ContextLoader:209 - Root WebApplicationContext: initialization completed in 906 ms
2011-3-2 15:07:34 org.apache.catalina.core.ApplicationContext log

```





```java

信息: Initializing Spring FrameworkServlet 'dispatcher'
15:07:34,015  INFO DispatcherServlet:277 - FrameworkServlet 'dispatcher': initialization started
15:07:34,015  INFO XmlWebApplicationContext:411 - Refreshing org.springframework.web.context.support.XmlWebApplicationContext@16477d9: display name [webapplicationcontext for namespace 'dispatcher-servlet']; startup date [wed mar 02 15:07:34 cst 2011]; parent: org.springframework.web.context.support.XmlWebApplicationContext@18c56d
15:07:34,015  INFO XmlBeanDefinitionReader:323 - Loading XML bean definitions from ServletContext resource [/web-inf/dispatcher-servlet.xml]
15:07:34,046  INFO XmlWebApplicationContext:426 - Bean factory for application context [org.springframework.web.context.support.xmlwebapplicationcontext@16477d9]: org.springframework.beans.factory.support.DefaultListableBeanFactory@c063ad
15:07:34,062  INFO DefaultListableBeanFactory:414 - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@c063ad: defining beans [checkcodecontroller,usercontroller,org.springframework.context.annotation.internalcommonannotationprocessor,org.springframework.context.annotation.internalautowiredannotationprocessor,org.springframework.context.annotation.internalrequiredannotationprocessor,velocityconfig,viewresolver,multipartresolver]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@15fc40c
15:07:34,093  INFO VelocityConfigurer:222 - Loading Velocity config from [servletcontext resource [/web-inf/velocity.properties]]
15:07:34,109  INFO VelocityConfigurer:138 - ClasspathResourceLoader with name 'springMacro' added to configured VelocityEngine
15:07:34,375  INFO DispatcherServlet:296 - FrameworkServlet 'dispatcher': initialization completed in 360 ms
2011-3-2 15:07:34 org.apache.coyote.http11.Http11Protocol start

```


<span style="color:red">注意两点：</span>

<span style="color:blue">1、Spring applicationContext先启动，servlet context后加载
2、dispatcher-servlet.xml中定义了控制器映射，使用Controller+RequestMapping注解映射时，相关controller组件扫描要定义在dispatcher-servlet.xml中，而非applicationContext.xml中。</span>