Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sring循环依赖的三种情况 #13

Open
DayThink opened this issue Feb 7, 2018 · 0 comments
Open

Sring循环依赖的三种情况 #13

DayThink opened this issue Feb 7, 2018 · 0 comments

Comments

@DayThink
Copy link

DayThink commented Feb 7, 2018

Spring中一个bean依赖于另一个bean的时候,可以通过构造器注入或setter注入,其中setter注入又可以分为单例和多例(prototype)。
1.如果是构造注入或多例模式的setter注入的时候,循环依赖是解决不了的;
2.如果是单例setter注入则可以解决掉循环依赖问题。原因在于Spring是先将Bean对象实例化之后再设置对象属性的而不是一次性将bean对象连同属性一起构造的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant