Spring ClassPathXmlApplicationContext和FileSystemXmlApplicationContext
先说:ClassPathXmlApplicationContext
这个类,默认获取的是WEB-INF/classes/下的路径,也就是在myeclipse的src下的路径,所以用这个是获取不到WEB-INF下的配置文件的...
下面是几个用法,引src下的一个文件,有以下几种方式
BeanFactory factory = new FileSystemXmlApplicationContext(new String[]{"classpath:applicationContext.xml","classpath:applicationContext*.xml"});BeanFactory factory = new FileSystemXmlApplicationContext("classpath*:applicationContext*.xml");
黑色头发:http://heisetoufa.iteye.com/ 1 楼 lixinanwen321 2012-09-08 如何读取非web项目的非src目录下的配置文件
目录结构如下:
--|
src
--|
test
--|
config--|
*.xml
如何读取config下的*.xml.