Search code examples
springcycle

Cyclic dependencies in Spring


IF I have bean A which refer to bean B and bean B depends upon bean A. In this scenario spring throws ObjectCurrentlyInCreationException ,but how internally it happen and on which object it will throw this error. For Eg:

<bean id='A'>
    <ref bean='B'>
</bean>



 <bean id='B'>
      <ref bean='A'>
 </bean>

Solution

  • If your classes A and B have default constructors (A(), B()), I believe everything should go well. Possible dupe of this question: Circular dependency in spring