Spring IOC configuration and application

Source: Internet
Author: User

1. FAQ: Do not prompt: a) window-preferences-myeclipse-xml catalogb) User Specified Entries-add I. location: D: \ share \ 0900_Spring \ soft \ spring-framework-2.5.6 \ dist \ resources \ spring-beans-2.5.xsd ii. URI: file: // D:/share/0900_Spring/soft/spring-framework-2.5.6/dist/resources/spring-beans-2.5.xsd iii. keyType: Schema Location iv. key: http://www.springframework.org/schema/beans/spring-beans-2.5.xs D2. injection type a) Spring_0300_IOC_Injection_Typeb) setter (important) c) constructor (you can forget) d) interface injection (you can forget) 3. id. namea) Spring_0400_IOC_Id_Nameb) name can use special characters 4. injection of simple attributes a) Spring_0500_IOC_SimplePropertyb) <property name =... Value =...> 5. <scope attribute a in bean) Spring_0600_IOC_Bean_Scopeb) singleton example c) proptotype each time a new object is created 6. Set injection a) Spring_0700_IOC_Collectionsb) is rarely used, not important! Reference Program 7. automatic Assembly a) Spring_0800_IOC_AutoWireb) byNamec) If all beans use the same type, you can use the properties of beans: default-autowire8. life cycle a) Spring_0900_IOC_Life_Cycleb) lazy-init (not important) c) init-method destroy-methd should not be used with prototype (understanding) 9. annotation Step 1: a) modify the xml file. For more information, see <context: annotation-config/> 10. @ Autowireda) default by type by typeb) If you want to use byName, use @ Qulifierc) to write in private field (third injection form) (not recommended, destroy encapsulation) d) if it is written on set, @ qualifier needs to be written on parameter 11. @ Resource (important) a) Add: j2ee/common-annotations.jarb) by name by default, name not found, by type c) can specify a specific name d) Recommended use e) Insufficiency: without source code, you cannot use annotation. You can only use xml12. @ Component @ Service @ Controller @ Repositorya. The default name is lower case B of the class name. You can specify the name of the bean to be initialized. 13. @ Scope14. @ PostConstruct = init-method; @ PreDestroy = destroy-method;

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.