文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 高级Bean--Spring快速参考
侵权投诉

高级Bean--Spring快速参考

高级Bean--Spring快速参考

高级Bean--Spring快速参考
一、继承
1.抽象bean
父bean通常作为子bean定义的模板使用,为了防止其初始化,可设置abstract属性
<bean id="template" classs="templateClass" abstract="true"/>
<!--class属性可省略,因为容器将忽略此行-->
2.子bean
定义parent属性
以上两点特性主要是为了配置文件的简练而设置
二、高级依赖注入
1.属性值
1)配置:
<beans>
<bean id="parent" class="Parent" singleton="false">
<property name="age"><value>30</value></property>
<property name="son">
<bean class="Son">
<property name="age"><value>30</value></property>
</bean>
</property>
<property name="age"><value>30</value></property>
</bean>
<bean id="son2" class="Son">
<property name="age">
<bean id="parent.son.age"
class="org.springframework.beans.factory.config.PropertyPathFactorybean"/>
</property>
</bean>
</beans>
2)以上配置将parent.son.age注入到son2.age属性
在以上配置中添加
<bean id="son1" class="org.springframework.beans.factory.config.PropertyPathFactorybean">
<property name="targetBeanName">
<value>parent</value>
</property>
<property name="propertyPath">
<value>son</value>
</property>
</bean>
上述配置将son1初始化为parent的son
3)也可将基本属性类型的属性值定义为bean实例,例如,对于theAge变量
<bean id="theAge" class="org.springframework.beans.factory.config.PropertyPathFactorybean">
<property name="targetBeanName">
<value>parent</value>
</property>
<property name="propertyPath>
<value>son.age</value>
</property>
</bean>
4)嵌套bean
<bean id="theAge2" class="org.springframework.beans.factory.config.PropertyPathFactorybean">
<property name="targetBeanName">
<bean class="Parent">
<property name="age"><value>12</value></property>
</bean>
</property>
<property name="propertyPath">
<value>age</value>
</property>
</bean>


2.field注入
配置
<beans>
<bean id="son3" class="Son">
<property name="age">
<bean id="java.sql.Connection.TRANSACTION_SERIALIZABLE"

第1页

你可能喜欢

热门文档

相关文档

  • -spring

    </beans> 该配置模版可以从spring的参考手册或spring的例子中得到。配置文件的...高级软件人才实作培训专家! 从spring容器中得到bean 当spring容器启动后,因为...

  • Spring框架中配置bean的高级属性

    Spring框架中配置bean的高级属性 比较不错比较不错隐藏>> 准备工作: 可以利用hibernate tools生成相关映射文件已经po对象、dao对象,dao也可以自己手动编写,无非就是...

  • Spring_后处理Bean让Bean了解容器

    Spring_后处理Bean让Bean了解容器_计算机软件及应用_IT/计算机_专业资料。Spring后处理Bean,让Bean了解容器高级Bean 的装配 父子 Bean 的创建 引用外部资源文件的 ...

  • Spring结合Struts开发

    struts和Spring结合 3页 1下载券 喜欢此文档的还喜欢 高级Bean--Spring快速参...Spring 整合 Struts 开发 JavaEE 应用程序 学术部 张亚涛 同学们是否听说过控制...

  • 高级法语教程-教学辅导参考书

    8 Le?on 29 Le?on 30 Le?on 31 Le?on 32 课文参考译文 练习答案 课文参考译文 练习答案 课文参考译文 练习答案 课文参考译文 练习答案 高级法语教程——教学...

  • spring-framework3.1 参考指南(英文版)

    spring-framework3.1 参考指南(英文版)_IT/计算机_专业资料。spring-framework...Bean overview ......

  • Spring的Bean功能

    3.5 与容器交互 Spring 容器本质上是一个高级“工厂”,负责产生 bean 的实例。容器通常有2种表现形式: BeanFactory ApplicationContext <chsdate w:st="on" year...

  • 气相色谱快速参考

    有关详细信息, 请参阅 Agilent 7890A GC 高级用户指南和位于 Agilent 文档和实用程序 DVD (仪器附带)上的完整套装文档。 10 快速参考 运行键 [Stop] (停止) ...

  • 第六章 Spring - Bean初始化方案

    第六章 Spring - Bean初始化方案_电脑基础知识_IT/计算机_专业资料。SpringBean初始化方案 初始化接口方案 Bean开发: public class User implements InitializingBean...

  • Spring-3-装配Bean

    Spring-3-装配Bean_计算机软件及应用_IT/计算机_专业资料。介绍Spring里面的bean的装配Spring 第三课 装配Bean IoC与Bean装配 ? 在Spring中,对象间的协作是通过...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email