Spring中如何加载多个配置文件

1.第一种,使用数组

代码

ApplicationContext contex=new ClassXmlApplicationContext(bew String["a1.xml","a2.xml"]);

2.第二种,只用通配符

代码

ApplicationContext contex=new ClassXmlApplicationContext("a*.xml");

//但此种方法只对文件系统中的xml文件有效,针对jar包中的无效

3.第三种,引入

代码

ApplicationContext contex=new ClassXmlApplicationContext("a1.xml");//在a1.xml中//执行resource路径为相对a1.xml的路径

用最少的悔恨面对过去

Spring中如何加载多个配置文件

相关文章:

你感兴趣的文章:

标签云: