<!--创建方式1:空参构造创建-->
<bean name="user" class="com.evergrande.User"
init-method="init" destroy-method="destroy"
></bean>
@test
public void fun5() {
ClassPathXmlApplicationContext ac = new
ClassPathXmlApplicationContext("file:D:\\WorkSpace\\springday01\\src\\applicationContext.xml");
User u = (User) ac.getBean("user");
System.out.println(u);
//关闭容器
ac.close();
}
对象创建时先调用构造方法构建之后调用初始化方法初始化
销毁时调用destroy方法
在大型项目中需要配置的Bean很多,可以在主配置文件中引入其他配置文件
<!--模块化配置 引入其他spring配置文件-->
<!--<import resource=""></import>-->