Spring <property>属性说明
(2013-03-21 16:15:25)
标签:
spring<property>属性it |
分类: java框架 |
说明:用于设置一个属性。
1.1
name属性
说明:属性的名称。
1.2
value属性
说明: 指定bean的属性值。BeanFactory将自动根据Java Bean对应的属性类型加以匹配。如果需要将属性值设定为null,必须使用<null/>节点。
1.3
ref属性
说明: 指定了属性对BeanFactory中其他Bean的引用关系。
bean属性:指定了属性对BeanFactory中其他Bean的引用关系。可以跨xml文档,同时bean属性的值可以和依赖的Bean的id属性相同,也可以和name属性相同。
local属性:指定了属性对BeanFactory中其他Bean的引用关系。(仅在本地(同一个)xml文件里寻找bean。
parent属性:指定了属性对BeanFactory中其他Bean模板的引用关系。容许应用当前BeanFactory或ApplicationContext的父BeanFactory或者 ApplicationContext中的Bean,同时bean属性的值可以和依赖的Bean的id属性相同,也可以和name属性相同。 像上面 ref默认属性为bean 。
1.4
<list>
说明:指定bean的属性类型为List的属性值。
1.5
<map>
说明:指定bean的属性类型为List的属性值。
1.6
<set>
说明:指定bean的属性类型为List的属性值。
1.7
<props>
说明:指定bean的属性类型为Properties的属性值。
<prop>
key属性:指定Properties的键
1.8
<idref>
说明:用来设置属性值为容器中其他bean的id 或name。
1.9
<null>
说明:指定一个空值。
1.10<constructor-arg>
说明:使用构造方法注入,指定构造方法的参数。
index属性:设置参数的序号。
ref属性:同ref
type属性:参数类型。
value属性:参数的值。
1.11<lookup-method>
说明:lookup方法注入
bean属性:要注入的bean名
name属性:要注入的方法名称
1.12<replaced-method>
说明:用来把已存在的方法实现替换为其他的实现。
name属性:要替换的方法名
replacer属性:替换者类,实现org.springframework.beans.factory.support.MethodReplacer 接口)
1.13<arg-type>
说明:方法返回的类型