5. Spring Config bean via XML (Advanced)

Source: Internet
Author: User

1. Set the scope of the bean

When you create a bean instance from a Spring IOC container, you can not only instantiate the bean, but also specify a specific scope for the bean, and Spring supports the following 5 scopes:

1. Singleton: Single case mode. In the entire IOC container, the bean instance defined with Singleton will have only one.

2. Prototype: Prototype mode, each time a prototype defined bean is obtained through the container's Getbean method, a new bean instance is generated

3. Request: For each HTTP request, the bean defined with the request will produce a new instance, that is, each HTTP request will produce a different bean instance. The scope is valid only if you are using spring in a web app

4.session: For each HTTP session, a new instance is generated using bean Soymilk defined by session. The scope is also valid only if spring is used in the Web App

5. Spring Config bean via XML (Advanced)

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.