3.7. Bean definition inheritance

3.7 Bean definition inheritance


<bean id="inheritsWithDifferentClass"
class="org.springframework.beans.DerivedTestBean"
parent="inheritedTestBean" init-method="initialize">

こうやると、idがinheritedTestBeanのbean定義をプロパティ継承できる。プロパティは継承先で上書きもできる。なおdepends on, autowire mode, dependency check, singleton, scope, lazy-init属性については継承されない。

ちなみに親の定義でBeanのインスタンス生成しないがプロパティ継承するためだけに定義する場合は



みたいにabstract=trueにしとけ。クラス定義がな場合はtrueにしないとエラーだ。