Spring lazy loading and depends-on

Source: Internet
Author: User

① Delayed Bean initialization (inert Bean initialization) means creating and initializing Beans only when they are actually used, instead of initializing beans in advance. the configuration method is simple. You only need to specify the "lazy-init" attribute value as "true" on the <bean> tag to delay Bean initialization. Configuration File: HelloWorld. xml <bean id = "helloApi" class = "cn. javass. spring. chapter2.helloworld. helloImpl "lazy-init =" true "/> www.2cto.com ② depends-on indicates the sequence of Bean initialization and destruction, the Bean specified by the depends-on Attribute must be initialized before the current Bean is initialized. Because only the "singleton" Bean can be managed and destroyed by Spring, therefore, when the specified Bean is "singleton", the Bean specified by the depends-on Attribute must be destroyed after the specified Bean. Configuration code: <bean id = "helloApi" class = "com. feng. spring. chapter2.helloworld. helloApi "> </bean> <bean id =" decorator "class =" cn. javass. spring. chapter3.bean. helloApiDecorator "depends-on =" helloApi "> <property name =" helloApi "> <ref bean =" helloApi "/> </property> </bean>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.