Spring <bean> parametric significance

Source: Internet
Author: User

1.id

The unique identity of the bean,

2.class

The fully qualified name of the class,

3.parent

The name of the parent class bean definition.

If there is no declaration, the parent bean is used, but the parent class can be overridden. When overriding a parent class, the child bean must be compatible with the parent bean, which means that

Accepts the value of the parent class's property value and the constructor declaration.

The child bean inherits the value of the parent bean's constructor declaration, the property value, and overrides the parent bean's method. If the Init method, the Destroy method is declared,

They will overwrite the corresponding settings of the parent bean.

The reserved settings are obtained directly from the child bean, including depends On,autowire Mode,scope,lazy init.

4.abstract

Declares whether the bean is abstract and determines whether the class will be instantiated. The default is False.

Note: The abstract property does not inherit from the quilt bean, so the declaration needs to be displayed for each bean when abstract is true.

5.lazy-init

Determines whether the instantiation is deferred, and if false, the singleton pattern Bean is instantiated immediately at startup. The default is False.

Note: The Lazy-init property does not inherit from the quilt bean.

6.autowire

Determines whether the properties of the bean are automatically assembled.

The Autowire has 4 modes:

    • "No"

The spring default mode. The bean reference must be defined in the XML file through the <ref/> element or ref attribute.

Spring recommends a pattern that will make the document clearer.

    • "ByName"

Use automatic assembly by property name. If a cat class has a dog attribute, spring will be based on the name of the dog

To find the bean, if the bean is not found, it will not be assembled automatically.

    • "Bytype"

If the spring container has only one bean of that property type, it is automatically assembled. When there are multiple beans of this property type

Will error. If not, it will not be assembled automatically.

    • "Constructor"

For constructor references, similar to Bytype.

Note: The Autowire property does not inherit from the quilt bean.

7.depends-on

The Bean factory ensures that other beans are initialized before the bean is initialized by the name of the other bean that is dependent on the bean initialization.

Note: A dependency is generally declared by a bean property or constructor, which is necessary for other dependencies, such as the preparation of a static class or a startup phase database.

Note: The Depends-on property does not inherit from the quilt bean.

8.scope

There are four types of scope property values: Singleton,prototype,request,session

Singleton: Singleton mode, default option

Prototype: non-singleton mode

Request: For a web app, each request produces a new instance

Session: For Web applications, a session produces an instance

I have limited level, if wrong, please correct me.

There are several options that you need to view your documents yourself.

9.autowire-candidate

10.primary

11.init-method

12.destroy-method

13.factory-method

14.factory-bean

Spring <bean> parametric significance

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.