Creating lazily initialized Spring beans using annotation based configuration

风流意气都作罢 提交于 2019-11-30 20:59:46

To declare lazy-initialized bean you can use @Lazy annotation.

Note, however, that it doesn't make sense for prototype beans - they can't be eagerly initialized, so there is no need to mark them lazy.

Lazy initialization isn't an option in the context of prototype-scoped beans. Those beans are instantiated and initialized on demand every time something asks for them, so they are, by nature, lazily initialized.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!