Spring的核心技术(八)---依赖注入的示例(1)
来源:互联网 发布:炫踪网络怎么样 编辑:程序博客网 时间:2024/06/05 01:19
下面的示例使用了基于XML的配置元数据来配置基于Setter方法的依赖注入。这只是Spring的XML配置文件所指定的Bean定义的一小部分。
<bean id="exampleBean" class="examples.ExampleBean">
<!-- setter injection using the nested ref element -->
<property name="beanOne">
<ref bean="anotherExampleBean"/>
</property>
<!-- setter injection using the neater ref attribute -->
<property name="beanTwo" ref="yetAnotherBean"/>
<property name="integerProperty" value="1"/>
</bean>
<bean id="anotherExampleBean" class="examples.AnotherBean"/>
<bean id="yetAnotherBean" class="examples.YetAnotherBean"/>
public class ExampleBean {
private AnotherBean beanOne;
private YetAnotherBean beanTwo;
private int i;
public void setBeanOne(AnotherBean beanOne) {
this.beanOne = beanOne;
}
public void setBeanTwo(YetAnotherBean beanTwo) {
this.beanTwo = beanTwo;
}
public void setIntegerProperty(int i) {
this.i = i;
}
}
0 0
- Spring的核心技术(八)---依赖注入的示例(1)
- Spring的核心技术(六)---基于Setter的依赖注入
- Spring核心技术(三)——Spring的依赖及其注入(续)
- Spring核心技术(四)——Spring的依赖及其注入(续二)
- Spring核心技术(二)——Spring的依赖及其注入
- Spring依赖注入的简单示例(基于注解配置)
- Spring的核心技术(五)---基于构造器的依赖注入
- Spring的核心技术(七)---循环依赖
- spring--核心技术--依赖注入
- SSH深度历险(八) 剖析SSH核心原理+Spring依赖注入的三种方式
- Spring的核心机制(依赖注入)
- Spring的依赖注入(基于XML)
- Spring的依赖注入(即DI)
- spring 的依赖注入(DI)
- Spring依赖注入的简单示例(基于XML文件配置)
- (八)共享相同的依赖注入树
- 详解Spring的依赖/依赖注入(DI)
- 详解Spring的依赖/依赖注入(DI)
- Xcode 7.1 - Unable to find execution service for selected run destination
- H264中NAL帧识别
- OPENCV不规则ROI-圆形ROI
- 第四周 项目三 单链表应用(2)
- IBM SDK 6 垃圾回收(GC)策略之 optthruput
- Spring的核心技术(八)---依赖注入的示例(1)
- 第四周 项目三 单链表应用(3)
- 网络传输的加密与解密
- 第15周项目2-用哈希法组织关键字
- 多个fragment跳转被销毁,使其不销毁的办法
- java:toString()方法与err
- 第十五周项目2-用哈希法组织关键字(2)
- 第十二周项目三:图遍历算法实现
- c语言输入生日显示星座