Spring Technology (ii) ----- IOC

Source: Internet
Author: User

Spring Technology (ii) ----- IOC

Spring technology-IOC is also called dependency injection (DI)

(1) setter-based injection

(2) constructor-based injection

(3) Bean references


1. Create a Java Project. The name is springtest2. Create a package. The name is com. gxcme. springtest2.

2. Add the spring framework.

3. Create an Interface. The name is helloInterface. java.


<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + NC7Qwr2o0ru49mNsYXNzoaPD + ratio = "http://www.2cto.com/uploadfile/Collfiles/20140907/20140907092202246.png" alt = "\">

5. configure it in the applicationContext. xml file.


6. Create a new class. The name is helloMain. java. Then run


7. References between beans
Create an Interface. The name is personInterface. java.


Create a new class. The name is personImpl. java. Inherits the personInterface.


In the applicationContext. xml file.


Create a new class. The name is personMain. java. Then run





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.