spring的配置文件名称是随意的
spring的配置文件格式
<?xml version="1.0"encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="" class="" init-method="init" lazy-init="false" destory-method="destory">
</bean>
</beans>
实例化-初始化-释放
spring容器的实例化
1.在类路径(classpath)下寻找配置文件来实例化容器:ApplicationContext context = new ClassPathXmlApplicationContext(new Srtring[]{"applicationContext.xml"});
2.在文件系统路径下寻找配置文件进行容器实例化 ApplicationContext ctx = new FileSystemXmlApplicationContext(new String[]{“D:\\bean.xml”})
这种方式可以在测试时使用,但一般不推荐使用,因为在不同的操作系统下,路径的写法是不一样的。