Spring's IOC, spring object Initializes bean timing, spring container life cycle

Source: Internet
Author: User
IOC refers to the inversion of control, the creation of objects, initialization, destruction and other work to the spring container. The spring container controls the life cycle of the object.

Spring Object Initialization Bean timing:

By default, as long as a bean is configured in the Spring container, the container will instantiate the bean at startup, in Singleton mode.
If you set lazy-load mode (lazy-init= "true") in spring when you are preparing a file, the object is instantiated at Getbean.
If scope= "prototype", whatever the value of Lazy-init will only be created when used, when Struts2 's
When the action and spring container are integrated, the action scope is set to prototype.

Spring Container life cycle:



Start the Spring container
Create a HelloWorld object
Call the Init method of the HelloWorld object, the Init method is called by the spring container inside the
Extract the HelloWorld object from the client, the object calls the method
When the spring container is closed, execute the Destroy method: Note: Prerequisites: Must be a singleton, if multiple instances, does not work.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Spring's IOC, spring object Initializes bean timing, spring container life cycle

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.