首页 > 学院 > 开发设计 > 正文

Java基础 spring中如何加载多个配置文件

2019-11-17 04:35:42
字体:
来源:转载
供稿:网友
 

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的路径


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表