项目作者: Sudarshan-Gowda

项目描述 :
Lazy Loading in Spring Core
高级语言: Java
项目地址: git://github.com/Sudarshan-Gowda/Spring5-LazyLoading.git
创建时间: 2020-05-05T23:26:57Z
项目社区:https://github.com/Sudarshan-Gowda/Spring5-LazyLoading

开源协议:

下载


Spring5-LazyLoading

Lazy Loading in Spring Core

Introduction:

In Spring application by default “application context“ eagerly creates and initializes all singleton scoped beans during application startup itself. It helps in detecting the any bean configuration issues at early stage, in most of the cases. But sometimes, we may need to use some or all beans to be lazy initialized due to different project requirements.

Spring provides two easy ways to configure lazy initialization of beans


  1. Java based configuration

  2. XML based configuration

Java Based Configuration:

To work with Java side configuration, use @Lazy annotation to load the bean lazily.

XML Based Configuration:


  • To enable lazy loading for specific beans, use lazy-init=”true” attribute on bean definitions in bean configuration xml files.





  • In case to enable lazy loading for all beans, use default-lazy-init=”true” attribute on beans tag in bean configuration xml files.