Search code examples
javaspringcircular-dependency

Good practices on finding circular dependencies between spring beans


I have this exception:

SEVERE: Context initialization failedorg.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'myService': Bean with name 'myService' has been injected into other beans [otherService] in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.

Can anyone suggest good strategies for finding where the circular dependency comes from ?

I am currently looking through the context definition, but as you might imagine in a project of some maturity this takes quite a while.

So I'm generally looking for ideas on quickly finding circular bean dependencies.


Solution

  • Here's 2 tools that advertise dependency graph generation. I don't have any experience with them however.