2011-09-12 117 views
0

我有以下情況: enter image description here春:問題的setter依賴注入

我設置了豆(在applicationContext.xml中)如下:

... 
<bean id="bDaoImpl" class="BDaoImpl"></bean> 
<bean id="injBInA" class="ADaoImpl"> 
    <property name="b" ref="bDaoImpl"/> 
</bean> 
... 

爲什麼當我在使用 「B」 Object類ADaoImpl的值是否爲空?

+0

我有解決方案。抱歉。基本上,當我從應用程序上下文加載bean(ApplicationContext.getBean)時,不加載id =「injBInA」的bean,因此沒有執行注入。 – giulius

+0

如果您可以將問題標記爲「已回答」 –

回答

1

我有解決方案。抱歉。基本上,當我從應用程序上下文(ApplicationContext.getBean)加載bean不加載id =「injBInA」的bean因此從未執行注入