1. Provide the property names and types that depend on Spring to inject attributes to the program.
package com.hao947.ioc;public class UserService {private String name;private String year;public void setName(String name) {this.name = name;}public void setYear(String year) {this.year = year;}public void show() {System.out.println("show...." + name + "," + year);}}
2. Provides the setter method for this attribute (Standard encapsulated setter method)
3. The value of the resource provided by spring when the resource Bean is initialized
4. debugging
Public class IoCApp {@ Testpublic void hao947 () {// obtain the Bean and use Spring's factory class ApplicationContext act = new ClassPathXmlApplicationContext ("applicatioContext. xml "); // get BeanUserService us = (UserService) act. getBean ("userService"); // execute the us operation. show (); System. out. println (us );}}