相关疑难解决方法(0)

如何在Spring中连接相互依赖的bean?

我想声明两个bean并使用Spring依赖注入实例化它们?

<bean id="sessionFactory" class="SessionFactoryImpl">
 <property name="entityInterceptor" ref="entityInterceptor"/>
</bean>

<bean id="entityInterceptor" class="EntityInterceptorImpl">
 <property name="sessionFactory" ref="sessionFactory"/>
</bean>
Run Code Online (Sandbox Code Playgroud)

但Spring抛出一个异常,说"当前处于创建状态的FactoryBean从getObject返回null"

为什么相互依赖的bean布线不能在这里工作?我应该在任何地方指定defferred属性绑定吗?

java spring dependency-injection

19
推荐指数
1
解决办法
1万
查看次数

标签 统计

dependency-injection ×1

java ×1

spring ×1