假如有多个配置文件,分别在不同的目录。
- Spring-X01.xml 位于 conf01 文件夹里
- Spring-X02.xml 位于 conf02 文件夹里
- Spring-X03.xml 位于 conf03 文件夹里
传统的加载方式:
1 |
ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"Spring-X01.xml","Spring-X02.xml","Spring-X03.xml"}) |
整合配置文件到一个配置文件里,创建一个Spring-All-Module.xml文件
1 |
<beans ....> |
整合之后的加载方式:
1 |
ApplicationContext context = new ClassPathXmlApplicationContext("Spring-All-Module.xml"); |
近期评论