`

spring contextloader声明周期

阅读更多

spring contextloader声明周期

了解spring 声明周期的目的是:我们知道在哪些阶段可以执行相应的操作.

(a)spring 容器初始化阶段可以指定profile

比如根据操作系统的环境变量来指定相应的profile


在方法contextInitialized中,可以获取系统的环境变量,比如操作系统类型等,

但是无法获取我们在配置文件中设置的变量(通过properties文件),因为此时context还没有加载完成. 

 

(b)spring 容器加载完成之后,做一些数据库的链接操作

因为数据链接需要参数,而参数是从Environment中获取的,所以必须context加载完成之后,才能获取.


 

参考:http://m.blog.csdn.net/article/details?id=51919283

 

  • 大小: 231.4 KB
  • 大小: 391.7 KB
0
0
分享到:
评论

相关推荐

    spring-web-2.5.jar

    org.springframework.web.context.ContextLoader.class org.springframework.web.context.ContextLoaderListener.class org.springframework.web.context.ContextLoaderServlet.class org.springframework.web....

    spring源代码解析

    对于一个Spring激活的web应用程序,可以通过使用Spring代码声明式的指定在web应用程序启动时载入应用程序上下文(WebApplicationContext),Spring的ContextLoader是提供这样性能的类,我们可以使用 ...

    第17讲 Spring、hibernate和Struts2的整合

    ①在web.xml中配置ApplicationContext.xml,并使用ContextLoader监听器实例化spring容器 ②把action交给spring管理,即在spring配置文件中定义action Bean并使用依赖注入功能在action中注入业务Bean,同时修改作用域...

    SPRING API 2.0.CHM

    ContextLoader ContextLoaderListener ContextLoaderPlugIn ContextLoaderServlet ContextRefreshedEvent ContextSingletonBeanFactoryLocator ControlFlow ControlFlowFactory ControlFlowFactory.Jdk13...

    ContextLoader 加载xml

    NULL 博文链接:https://yjgyjg4.iteye.com/blog/662723

    struts2驱动包

    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:252) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:190) ...

    S2SH整合报错

    ERROR main org.springframework.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in...

    iriska:鸢尾花分类模型

    Iris model = new Iris ( new ContextLoader ()); Flower flower = Flower . builder() .setSepalLength( 5.57091678078844 ) .setPetalWidth( 3.09644861465126 ) .setPetalLength( 1.23725924762744 )

    realtor:Klassy的房地产经纪人回归模型

    =房地产经纪人= ... Houser model = new Houser ( new ContextLoader ()); House house = House . builder() .houseSize( 2983 ) .lotSize( 9365 ) .bedrooms( 5 ) .granite( 0 ) .bathroom( 1 ) .build

Global site tag (gtag.js) - Google Analytics