Spring:setter Dependency Injection的问题

时间:2011-09-12 14:33:30

标签: java-ee-6 spring-3

我有以下情况: enter image description here

我按如下方式设置bean(在applicationContext.xml中):

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

为什么当我在Object类的值中使用“b”时,ADaoImpl为null?

1 个答案:

答案 0 :(得分:1)

我有解决方案。抱歉。基本上当我从应用程序上下文(ApplicationContext.getBean)加载bean时,不会加载id =“injBInA”的bean,因此从未执行过注入