Spring的IOC机制,利用了java的反射机制,通过读取配置文件,动态生成所需要的类。
public static void main(String[] args) { // TODO Auto-generated method stub Resource rs = new FileSystemResource("helloMessage.xml"); BeanFactory bf = new XmlBeanFactory(rs); Person person = (Person)bf.getBean("person"); String s = person.sayHello(); System.out.println("The person is currently saying " + s); }
源码
https://git.oschina.net/zkzk945/Spring.git