首页 > 编程语言 > 详细

Spring的分模块开发的配置

时间:2020-02-28 11:30:16      阅读:52      评论:0      收藏:0      [点我收藏+]

参考:Spring学习笔记—Spring的分模块开发的配置

在加载配置文件的时候,加载多个

例如把applicationContext.xml配置文件中的关于集合配置的部分剪切到applicationContext2.xml中,在加载配置文件的时候,将两个配置文件全部加载。

1
2
3
4
5
6
7
8
public class  {

public void demo1(){
大专栏  Spring的分模块开发的配置"> ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml","applicationContext2.xml");
CollectionBean collectionBean= (CollectionBean)applicationContext.getBean("collectionBean");
System.out.println(collectionBean);
}
}

在一个配置文件中引入多个配置

在applicationContext.xml中用import标签引入applicationContext2.xml:

1
<import resource="applicationContext2.xml"/>

因为两个配置文件在同一个根目录下,所以可以直接写名字。

Spring的分模块开发的配置

原文:https://www.cnblogs.com/lijianming180/p/12375890.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!