因此,出於某種原因,我們項目的一半bean標記爲@Component,並使用@Autowired標註注入標記爲@Component的其他對象,而另一半則使用applicationContext.xml bean顯式連接聲明和屬性與ref bean值。顯式注入一個標記爲@Component的bean
問題是,在那些xml bean聲明中,我可以注入一個標記爲@Component的對象嗎?如果是這樣,它的bean引用名稱是什麼?
例如;
有些類是這樣註釋的;
@Component
public class BeanAImpl{ ... }
然後在applicationContext.xml中,其他類顯式連線,因爲它們沒有註釋;
<bean id="beanB" class="com.myapp.BeanBImpl"></bean>
我可以在applicationContext.xml中注入'種類'的bean嗎?
<bean id="beanUser" class="com.myapp.BeanUserImpl">
<property name="beanA">HOW_TO_GET_REF_TO_BEANA?</property>
<property name="beanB"><ref bean="beanB"/></property>
</bean>