Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Is there a lazy initialization option in mapper bean?


Asked by Itzel Spence on Dec 05, 2021 FAQ



@MapperScan requires Spring 3.1+. Since 2.0.2, mapper scanning feature support an option ( lazy-initialization) that control lazy initialization enabled/disabled of mapper bean. The motivation for adding this option is supporting a lazy initialization control feature supported by Spring Boot 2.2.
Just so,
Configuration for lazy initialization of Spring beans You can configure bean as lazy-initialized in both XML based configuration and Java based configuration. In XML configuration you need to add lazy-init attribute to the <bean/> element. In case of Java configuration you need to use @Lazy annotation.
And, @MapperScan requires Spring 3.1+. Since 2.0.2, mapper scanning feature support an option ( lazy-initialization) that control lazy initialization enabled/disabled of mapper bean. The motivation for adding this option is supporting a lazy initialization control feature supported by Spring Boot 2.2.
In respect to this,
In XML configuration you need to add lazy-init attribute to the <bean/> element. In case of Java configuration you need to use @Lazy annotation. Let’s see Spring example for both these type of configurations.
Besides,
There're several ways to tell the IoC container to initialize a bean lazily. 2.1. @Configuration Class When we put @Lazy annotation over the @Configuration class, it indicates that all the methods with @Bean annotation should be loaded lazily.