Home > Back-end >  Using the @ Autowried injection objects can avoid circular dependencies?
Using the @ Autowried injection objects can avoid circular dependencies?

Time:12-23

Development today, suddenly have a circular dependency problems, I really is also using the @ Autowried injection objects, but it still led to a circular dependencies, although it is coupling leads to the problem of the project, but I want to and you talk about, the spring inside is not according to the injection process of the bean can solve the problem of circular dependencies, but why would appear, thanks to the great god give directions,

CodePudding user response:

Test, in the spring structure problems circular dependency injection, injection and attributes but you can use @ Lazy Lazy loading way, the @autowired and Setter way,
Spring dependence on @autowired processing is actually from the cache dependencies in the ObjectFactory to create an instance of an object, not again to create dependent objects, so as to solve the problem of circular dependencies,

CodePudding user response:

May be used in different ways, also do not have met you the coupling circumstances, there may be other reasons
  • Related