spring容器启动
来源:互联网 发布:sql数据库远程连接 编辑:程序博客网 时间:2024/05/29 10:17
什么时候spring容器启动?
其实就是程序中执行加载 xml配置文件的时候
- 1.应用程序下加载
ApplicationContext ctx = new ClassPathXmlApplicationContext("testspring2.xml");
- 2.web模式下加载
web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-hibernate-mysql.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
可以看日志,每次执行new ClassPathXmlApplicationContext(),都会显示下面日志:
new ClassPathXmlApplicationContext("testspring2.xml");
2010-5-29 0:48:48 org.springframework.context.support.AbstractApplicationContext prepareRefresh
先刷新ApplicationContext,调用AbstractApplicationContext类的 prepareRefresh
注:
AbstractApplicationContext是 ClassPathXmlApplicationContext的父类
public abstract class AbstractApplicationContext extends DefaultResourceLoader
implements ConfigurableApplicationContext, DisposableBean {
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@bf32c: display name [org.springframework.context.support.ClassPathXmlApplicationContext@bf32c]; startup date [Sat May 29 00:48:48 CST 2010]; root of context hierarchy2010-5-29 0:48:48 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [testspring.xml]
开始加载spring配置文件,调用xml.XmlBeanDefinitionReader类的loadBeanDefinitions方法进行加载
注意:spring 和 hibernate 常见的错误之一,经常在读取xml文件时出现语法和格式的错误,如DTD错误等.多数是使用者自己在书写xml时犯的语法错误,但也有一些是hibernate和 spring不同版本的BUG2010-5-29 0:48:48 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
信息: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@bf32c]: org.springframework.beans.factory.support.DefaultListableBeanFactory@af8358
2010-5-29 0:48:48 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
获得缺省的工厂对象,spring缺省的工厂对象是
DefaultListableBeanFactory.preInstantiateSingletons信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@af8358: defining beans [personServiceBean]; root of factory hierarchy
最后为所有xml文件中定义(以及采用标注方式定义)的bean建立实例
0 0
- web容器启动spring容器
- Spring容器启动过程
- Spring容器启动过程
- Spring容器启动过程
- 手动启动spring容器
- java启动spring容器
- Spring容器启动过程
- web容器启动Spring
- Spring容器启动过程
- 单元测试启动spring容器
- Spring容器启动过程
- spring容器启动
- spring容器启动
- 手动启动Spring容器
- Web容器 与Spring容器 启动
- web项目启动Spring容器
- Spring 容器的启动方式
- spring容器 的启动过程
- 分布式服务框架 dubbo/dubbox 入门示例
- Java设计模式之简单工厂模式
- 【转】activiti用户任务
- spring容器启动
- Java直接发送邮件或写好的eml邮件
- spring容器启动
- 2. 常用的第三方WebService调用
- Highcharts学习笔记-line(内存使用监视)
- Bean声明周期中的post-initialization和pre-destruction .
- Bean声明周期中的post-initialization和pre-destruction .
- 【转】Spring的生命周期,一分钟看懂
- Highcharts学习笔记-饼状图(内存使用监视)
- 【转】Spring的生命周期,一分钟看懂
- Spring AOP网上例子整理(一)