首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 系统运维 >

Spring ClassPathXmlApplicationContext跟FileSystemXmlApplicationContext

2012-11-25 
Spring ClassPathXmlApplicationContext和FileSystemXmlApplicationContext先说:ClassPathXmlApplicationC

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.

热点排行