Spring配置多个xml的文件的多种方法
2011-09-23 21:24
513 查看
1.通过数组来读取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”/>
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”/>
相关文章推荐
- Spring根据XML配置文件注入属性的方法
- Spring中XML配置文件的十二个最佳方法(上)
- SpringMVC.xml配置文件 几种配置方法
- Spring中XML配置文件的十二个最佳方法(下)
- Spring中XML配置文件的十二个最佳方法
- Spring-property文件配置方法以及如何与工程分离~xml使用${}
- 读取Spring配置文件ApplicationContext.xml的5种方法
- Spring中XML配置文件的十二个最佳方法
- spring 实例化定义在xml配置文件中的bean的三种方法?
- Spring和Struts2配置文件不在默认路径下的web.xml配置方法
- 读取Spring的配置文件applicationContext.xml的5种方法
- 在Maven项目中加载spring中的bean的配置xml文件会提示找不到解决方法
- Spring ClassPathXmlApplicationContext和FileSystemXmlApplicationContext读取配置文件的方法
- Spring中c3p0连接池的配置 及JdbcTemplate的使用 通过XML配置文件注入各种需要对象的操作 来完成数据库添加Add()方法
- Spring的XML配置文件的十二个最佳方法实践
- Spring中加载XML配置文件的方法
- Spring的XML配置文件的十二个最佳方法实践
- Spring中XML配置文件的十二个最佳方法
- Spring中XML配置文件的十二个最佳方法(上)
- spring配置文件applicationContext.xml不能提示的解决方法