Summary of Spring Bean properties and child elements usage

Source: Internet
Author: User

Summary of Spring Bean properties and child elements usage2016-08-03 00:0097 people readComments (0)CollectionReport Category:Spring&springmvc (+)

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

Spring framework mainly has four kinds of tag beans, alias, import, beans, where the bean tag is the basis of other tags, this article mainly on the Bean tag properties and their child elements of the discussion, not much nonsense, please look down.

The attributes of the bean tag

1) Scope: The scope used to configure the spring bean

2) Singleton: Indicates that the Bean is a singleton

3) Abstract: Set to True to use the bean only as a template, the application context does not attempt to initialize it beforehand

4) Lazy-init: Set to True, lazy loading, the bean will not be instantiated in advance of ApplicationContext startup, but rather the first time it is instantiated to the container through Getbean request Bean

Note: only works with singleton beans

5) Autowire: Automatic assembly

6) Dependency-check: Dependency Check

7) Depends-on: Indicates that instantiation of one bean relies on another bean to instantiate first

8) Autowire-candidate: Set to False, the container will not consider the bean when it looks for an automatic assembly object, that is, it will not be considered as a candidate for automatic assembly of other beans, but the bean itself can use automatic assembly to inject other beans

9) Primary: The Bean is first injected

Init-method: The method that is called when the Bean is initialized

Destory-method: The method that was called before the container was destroyed

Factory-method: The bean is only started to be instantiated when the method pointed to by Factory-method is called

Factory-bean: Create a bean in a way that calls the static factory method

Second, the child element of the bean

1) Meta: Meta data, when needed to use the information inside can be obtained by key

2) Lookup-method: The fetch is injected to declare a method to return some type of bean but the actual bean to be returned is configured in the configuration file.

3) Replaced-method: The new method can be called at runtime to replace the existing method, and the logic of the old method can be updated dynamically

4) Constructor-arg: The bean is automatically searched for the corresponding constructor, and when initialized, the parameters are passed in.

5) Property: Basic Data type Assignment

6) Qualifier: Specify the name of the injected bean by qualifier



















Source: >  

From for notes (Wiz)

Summary of Spring Bean properties and child elements usage

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.