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

提前实例化所有单例bean #77

Open
cr-skl opened this issue Aug 7, 2024 · 1 comment
Open

提前实例化所有单例bean #77

cr-skl opened this issue Aug 7, 2024 · 1 comment

Comments

@cr-skl
Copy link

cr-skl commented Aug 7, 2024

你好,我的问题是:
关于 application-context 分支中的 DefaultListableBeanFactory 类中的 preInstantiateSingletons() 方法, 为什么要把所有单例都进行实例化? 其余不是单例的类不需要提前实例化,只进行加载, 为什么要这样区别对待

@DerekYRC
Copy link
Owner

@cr-skl 提前实例化单例bean避免后续用到才实例化。prototype 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

2 participants