posts - 64,comments - 22,trackbacks - 0
     摘要: 使用Spring注解注入属性2009-06-15 17:48 kenshin54 JavaEye博客 我要评论(0) 字号:T | T本文介绍了使用Spring注解注入属性的方法。使用注解以前,注入属性通过类以及配置文件来实现。现在,注入属性可以通过引入@Autowired注解,或者@Resource,@Qualifier,@PostConstruct,@P...  阅读全文
posted @ 2011-11-21 12:31 hellxoul 阅读(1642) | 评论 (0)编辑 收藏

原文出自liuxilil
关键字: lazy-init,init-method,destroy-method,depends-on的说明

 lazy-init,init-method,destroy-method,depends-on的说明(这4个是Spring 1就有的)

  1. lazy-init是否延迟初始化
  2. init-method指定初始化方法
  3. destroy-method指定销毁方法
  4. depends-on指定依赖的bean(指定bean的初始化顺序)
    1 Xml代码 
    2 <bean id="bean11" class="test.impl.Bean11" lazy-init="true" init-method="init" destroy-method="destroy" depends-on="bean1"/>  
    3 <bean id="bean12" class="test.impl.Bean12" lazy-init="false" init-method="init" destroy-method="destroy" depends-on="bean2"/>  
    4   
    5 <bean id="bean1" class="test.impl.Bean1" init-method="init" destroy-method="destroy" lazy-init="true"/>  
    6 <bean id="bean2" class="test.impl.Bean2" init-method="init" destroy-method="destroy" />  

    说明:

    1  一个bean的生命周期是constructor->init->destroy
    2   lazy-init决定了bean的初始化时机  (bean1和bean11在被调用时,bean2和bean12在ApplicationContext初始化时)
    3   depends-on决定了beans的初始化顺序(bean11在bean1初始化后,bean22在bean2初始化后)和销毁顺序(bean11在bean1销毁前,bean22在bean2销毁前)
posted @ 2011-11-21 09:22 hellxoul 阅读(642) | 评论 (0)编辑 收藏
     摘要:
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.spr  阅读全文
posted @ 2011-11-19 15:44 hellxoul 阅读(51181) | 评论 (7)编辑 收藏
     摘要: 在spring2.0之前bean只有2种作用域即:singleton(单例)、non-singleton(也称prototype),Spring2.0以后,增加了session、request、global session三种专用于Web应用程序上下文的Bean。因此,默认情况下Spring2.0现在有五种类型的Bean。当然,Spring2.0对Bean的类型的设计进行了重构,并设计出灵活的Bean类型支持,理论上可以有无数多种类型的Bean,用户可以根据自己的需要,增加新的Bean类型,满足实际应用需求。  阅读全文
posted @ 2011-11-19 15:24 hellxoul 阅读(275) | 评论 (0)编辑 收藏
哈哈,今天开始自己的blog
posted @ 2011-11-19 15:05 hellxoul 阅读(116) | 评论 (0)编辑 收藏
     摘要:   阅读全文
posted @ 2011-11-19 15:02 hellxoul 阅读(214) | 评论 (0)编辑 收藏
仅列出标题
共7页: 上一页 1 2 3 4 5 6 7