私は春の博士のコアコンテナを読んでいましたrefの親のの目的を理解したいときに協力者を注入すると、親コンテキストの子コンテキストまたは親コンテナと現在のコンテナのこの概念が見つかりました。これは私が混乱する部分ですそれ:親属性を介してターゲットBeanを指定 This part of doc春の親コンテキストと子コンテキストの違いは何ですか?
は現在 のコンテナの親コンテナであるBeanへ の参照を作成します。親属性の値は、 ターゲットBeanのid属性、またはターゲットBeanの名前 属性の値のいずれかと同じであり、ターゲットBeanは親の コンテナに存在する必要があります1。このBean参照バリアント は、主にコンテナの階層を持ち、 既存のBeanを親コンテナにラップし、親Beanと同じ名前の を持つプロキシを使用する場合に使用します。
<!-- in the parent context -->
<bean id="accountService" class="com.foo.SimpleAccountService">
<!-- insert dependencies as required as here -->
</bean>
<!-- in the child (descendant) context -->
<bean id="accountService" <!-- bean name is the same as the parent bean -->
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target">
<ref parent="accountService"/> <!-- notice how we refer to the parent bean -->
</property>
<!-- insert other configuration and dependencies as required here -->
</bean>
誰かが私にいくつかの助けや文脈のこの2種類の例を与えることができますか?そして、REF親の目的は、事前
春のmvcが最高の例だとよく説明されています、ありがとう –