Spring 2.0中集合对象注入的复用
2007-09-26 17:39
471 查看
如果一个集合对象不光光是注入到一个对象中,那我们需要考虑此集合对象设置ID
List
<bean id="mails" class="org.springframework.beans.factory.config.ListFactoryBean">
<property name="sourceList">
<value>data1</value>
<value>data2</value>
<property>
</bean>
Map
<bean id="mails" class="org.springframework.beans.factory.config.MapFactoryBean">
<property name="sourceMap">
<map>
<entry key="data1" value="data1"/>
<entry key="data2" value="data2"/>
</map>
<property>
</bean>
Set
<bean id="mails" class="org.springframework.beans.factory.config.SetFactoryBean">
<property name="sourceSet">
<set>
<value>data1</value>
<value>data2</value>
</set>
<property>
</bean>
properties
<bean id="mails" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<props>
<prop key="somekey">somekey</prop>
<prop key="anykey">anykey</prop>
</props>
</bean>
<!---或者使用location属性->
<property name="localtion">
<value>src/config/config.properties</value>
</property>
List
<bean id="mails" class="org.springframework.beans.factory.config.ListFactoryBean">
<property name="sourceList">
<value>data1</value>
<value>data2</value>
<property>
</bean>
Map
<bean id="mails" class="org.springframework.beans.factory.config.MapFactoryBean">
<property name="sourceMap">
<map>
<entry key="data1" value="data1"/>
<entry key="data2" value="data2"/>
</map>
<property>
</bean>
Set
<bean id="mails" class="org.springframework.beans.factory.config.SetFactoryBean">
<property name="sourceSet">
<set>
<value>data1</value>
<value>data2</value>
</set>
<property>
</bean>
properties
<bean id="mails" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<props>
<prop key="somekey">somekey</prop>
<prop key="anykey">anykey</prop>
</props>
</bean>
<!---或者使用location属性->
<property name="localtion">
<value>src/config/config.properties</value>
</property>
相关文章推荐
- Spring (三)注入依赖对象、注入集合类型的属性
- 快速上手Spring--8. 集合对象注入
- Spring 2.0中集合对象的合并
- Spring -------集合对象注入
- Spring 2.0技术手册 -2 集合对象
- 快速上手Spring--8. 集合对象注入
- Spring入门10 - 集合对象注入
- Spring系列【08】为JavaBean的集合对象注入属性值
- 快速上手Spring--8. 集合对象注入
- 【Spring】【对<bean>注入各种信息】【简单属性,对象属性,集合属性,构造器】
- 【JavaEE学习笔记】Spring_02_IoC/DI依赖注入,集合对象属性注入,自动装配,代理模式
- spring:为javabean的集合对象注入属性值
- 快速上手Spring--8. 集合对象注入
- quartz的job中注入spring对象!
- 85——Spring中对象依赖注入,给对象属性赋值,包含哪些内容(1条)
- Spring入门Blog[二、Ioc控制反转集合注入和Scope]
- Spring入门之bean属性注入集合
- spring不通过注入的方式获取对象(BeanFactoryAware \ApplicationContextAware )
- 集合的遍历以及在Spring中的注入
- Spring源码分析--@Autowired注入的不是代理对象,导致事务回滚失败(@Transactional无效)