The instantiation of the spring Learning Note bean

Source: Internet
Author: User

One, there are 3 instances of the Bean method,

1. Constructor instantiation

2. Static Factory method instantiation

3. Instance Factory method instantiation

Second, use the constructor to instantiate

<bean id= "Shundao" class= "test. Ftpdao ">

ID or name to specify the name of the bean, class to specify the type of bean

Iii. instantiation of Static factory methods

<bean id= "Shundao" class= "test. Ftpdao "factory-method=" getinstance ">

Factory-method is used to specify a method for creating a bean object in a factory, which must be static

Iv. Instance Factory method instantiation

<bean id= "Cal1" class= "Java.util.Calendar" factory-method= "getinstance" ></bean>
<bean id= "Cal3" class= "Java.util.Date" factory-bean= "Cal1" factory-method= "GetTime" ></bean>

The instantiation of the spring Learning Note bean

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.