tags:

views:

37

answers:

2

greetings all sometime in my app the logic forces me to use circular reference and i want to know how to enable this configuration in spring ?

A: 

Spring has no problems with circular references. BeanA can be wired with BeanB, and vice versa. You only get problems with circular references if you introduce them yourself in your code.

If you have a specific issue, please elaborate.

skaffman
I have Dao1 and Dao2:1-in Dao1 i autowire Dao22-in Dao2 i autowire Dao1my logic forces my to this and i am getting the excpetion of BeanCurrentlyInCreation coz of circular refernceand i want to allow this type of autowiring or do a workaround.
sword101
@sword101: Please add these details to the original question, with concrete examples.
skaffman
@sword101 In that case you should probably move that logic up into your service layer, and autowire both daos into the Service.
BrennaSoft
+1  A: 

Take a look at this article.

I would advice from the first option there. Circular dependencies are not a good sign and should be avoided. You can create a 3rd, helper class, for example.

The other two options are workarounds and will be harder to understand and debug later on.

Bozho