Spring提供Beans 作为 IoC 容器,存放我们需要使用的对象,使用时向其请求并自动返回对象。

需要创建应用程序上下文,其代表着IoC容器,负责实例化、配置和组装Bean:

public static void main(String[] args) {
  	//ApplicationContext是应用程序上下文的顶层接口,它有很多种实现,这里我们先介绍第一种
  	//因为这里使用的是XML配置文件,所以说我们就使用 ClassPathXmlApplicationContext 这个实现类
    ApplicationContext context = new ClassPathXmlApplicationContext("test.xml");  //这里写上刚刚的名字
}