Spring配置的parent属性和java属性是相同的吗?
来源:互联网 发布:单片机电路图 编辑:程序博客网 时间:2024/06/16 05:28
Spring配置的parent属性和java属性是相同的吗?
本质上来说不同,Spring的parent的属性只是一个标签,用来创建实例的模板.简单来说,就省了注入属性的代码,可以把parent指向的bean的注入属性一起加进来。和方法无关。
SO的回答:
In spring, the parent in bean configuration signifies configuration inheritance and not related to Java inheritance.
The configuration inheritance saves a lot of code as you do away with repeated XML code.
For example, you have following bean with attributes
Class MyBean { attrib1 attrib2 attrib3 attrib4}
Say one instance of bean say bean1 just needs attrib1 and attrib2 whereas >another say bean2 instance needs all four the attributes.
Lets configure these two beans
<bean id="bean1" class="MyBean"> <property name="attrib1" value="val1" /> <property name="attrib2" value="val2" /></bean>
Note that bean2 just needed to configure attrib3 and attrib4. The other >two attributes are inherited from bean1To answer your question:
Does it is required to specify both springs in order to implement inheritance?
No. As mentioned earlier this is not the same as java inheritance.
- Spring配置的parent属性和java属性是相同的吗?
- Spring配置中 bean上的属性parent的作用
- Spring的bean标签的scope和parent属性
- Spring的bean标签的scope和parent属性
- Spring bean里的parent属性
- Parent属性的另类用法
- Parent属性的另类用法
- spring源码(11)bean的parent属性详解和获取RootBeanDefinition
- Java 对象之间相同属性的赋值
- Spring的bean属性配置
- spring bean parent属性详解
- spring bean parent属性详解
- spring bean parent 属性浅析
- spring中parent属性解析
- spring bean parent属性详解
- spring 依赖对象的注入方式(3种) 和 公共属性的设置abstract="true" parent
- spring中使用parent属性来减少配置
- spring中使用parent属性来减少配置
- 【例题】【线段树】lazy
- Android消息处理机制(Handler、Looper、MessageQueue与Message)
- MyBatis
- 双向广搜模版(360百科)
- python的基本知识
- Spring配置的parent属性和java属性是相同的吗?
- 逆地址解析
- Ubuntu 14.04 上安装 CUDA 7.5/8.0 超详细教程
- Git和SVN之间的五个基本区别
- Palindrome Linked List
- File数据存储
- Hadoop源代码分析(一二)
- 【TJOI & HEOI 2016】【JZOJ 4604】【BZOJ 4551】 树
- QuickContactBadge的用法