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

doCreateBean #25

Open
gdhzLZ opened this issue Dec 9, 2021 · 3 comments
Open

doCreateBean #25

gdhzLZ opened this issue Dec 9, 2021 · 3 comments

Comments

@gdhzLZ
Copy link

gdhzLZ commented Dec 9, 2021

请问AbstractAutowireCapableBeanFactory#doCreateBean方法中返回之前会执行getSingleton,那之前的applyPropertyValues,initializeBean等工作不就白做了嘛?还是我哪里理解的有问题?

@DerekYRC
Copy link
Owner

DerekYRC commented Dec 9, 2021

AbstractAutowireCapableBeanFactory

不是很明白你的问题。AbstractBeanFactory$getBean中执行getSingleton从单例缓存中查询bean,查询不到就走后面的创建bean实例、applyPropertyValues、initializeBean等等流程。

@gdhzLZ
Copy link
Author

gdhzLZ commented Dec 9, 2021

image
在返回前重新调用了getSingleton,是不是会导致前面的初始化白做了呢

@DerekYRC
Copy link
Owner

DerekYRC commented Dec 9, 2021

不会。这行代码设计到循环依赖的解决方案,建议阅读changelog文件内容了解代码改动点。

@DerekYRC DerekYRC closed this as completed Dec 9, 2021
@DerekYRC DerekYRC reopened this Nov 24, 2022
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

2 participants