您的位置:首页 > 编程语言 > Java开发

Spring配置多个xml的文件的多种方法

2011-09-23 21:24 513 查看
1.通过数组来读取xml配置文件
public ClassPathXmlApplicationContext(String[] configLocations)throws BeansException {
this(configLocations, (ApplicationContext) null);
}


例:

ClassPathXmlApplicationContext(new String[]{“services.xml”,”daos.xml”});

2.通过配置文件的命名方式来读取,使用通配符

new ClassPathXmlApplicationContext(“appliicationContext-*.xml”);

3.在xml配置文件中通过import标签引入其它xml配置文件,在加载的xml中定义子xml
例:在applicationContext-map.xml文件中引入其他2个配置文件,如下:
<import resource=”applicationContext-list.xml”/>
<import resource=”applicationContext-aaa.xml”/>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: