Spring中关于xml导入其他xml问题

如果我们在spring框架中配置了多个xml文件,我们可以在读取配置文件的时候把这些xml文件一下全都读取,也可以只读一个总的xml文件,在这个总的xml文件中把其他的xml全都都导入进来。
例如:
有一个名字叫student.xml的配置文件和teacher.xml的配置文件把他们导入到新的配置文件中
新建一个名字为import.xml的配置文件:
<import resource="teacher.xml"/>
<import resource="student.xml"/>
就可以把之前的两个xml文件导入该文件下,再通过java的类
String[] path = {"com/ioc/imp/import.xml"};
ApplicationContext container = new ClassPathXmlApplicationContext(path);
就可以直接读取一个或多个文件

猜你喜欢

转载自blog.csdn.net/notMoonHeart/article/details/78463572