Description of XML configuration file properties in Spring

Source: Internet
Author: User

description of the XML configuration file properties:

<bean id= "Theaction" ⑴

class= "Net.xiaxin.spring.qs.UpperAction" ⑵

Singleton= "true" ⑶

Init-method= "Init" ⑷

destroy-method= "Cleanup" ⑸

depends-on= "ActionManager" ⑹>

<property...>

</bean>

⑴id

The unique identifier of the Java Bean in beanfactory , which is obtained through beanfactory in the code .

This is used as the index name for JavaBean instances.

⑵class the Java Bean class name is the implementation class for the real interface.

        ⑶ singleton bean prototype or singleton  

Singleton (Singleton) mode, if set to "true", only one instance of this Java Bean is maintained, and Conversely, if set to "False",beanfactory will create a new instance each time it returns. The default is true.

The way to do it is for the first timeGetbeanwhen placedMapThe second time, and then directly in theMapin the class namedKey, the instance isvalue. BeanAdditional scopes forprototype: Prototype mode: in Getprototypedefined byBeangeneration of new instances, whose life cycle is maintained by the client. Sessionfor eachHTTPsessionto produce a new instance. Global Sessiononly when usingPortletcontextis effective when it is used.Singletonand theprototype

⑷init-method

Initializes the method, which executes after beanfactory creates the JavaBean instance before returning the reference to the application layer. Typically used for initialization of some resources. Create the init method in JavaBean, and then add the property init-method= "Init" .

⑸destroy-method

Method of Destruction. This method is executed when the beanfactory is destroyed, and is typically used for resource deallocation. Similar to init usage

⑹depends-on

The Bean dependency relationship. In general, no setting is required. Spring organizes the construction of individual dependencies according to the circumstances (the depends-on attribute in this example is not required).

Only some special cases, such as some static variables in JavaBean, need to be initialized (this is a Badsmellthat should be avoided in design). specifying its dependencies through depends-on will ensure that the resources specified by depends-on are loaded first before this Bean is loaded .

⑺<value>

         through <VALUE/> beanfactory will be automatically based on the java bean  

The following "desc" property provides an Example of setting a null value. Note <value></value> represents an empty string, and if you need to set the property value to null, you must use the < The null/> node.

⑻<ref> Specifies the reference relationship of the property to other beans in the beanfactory .

Description of XML configuration file properties in Spring

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.