spring中装载多个配置文件
1,web.xml中 spring-config org.springframework.web.servlet.DispatcherServlet contextConfigLocation /WEB-INF/conf/spring-config.xml,/WEB-INF/applicationContext.xml 1 contextConfigLocation /WEB-INF/applicationContext-hibernate.xml,/WEB-INF/applicationContext.xml org.springframework.web.context.ContextLoaderListener 2.使用ClassPathApplicationContext。这个类会自动从classpath目录中加载所有的配置文件,不过这个类好像只适用本地调试时用的。 3.通过一个父配置文件将所有子配置文件导入。 在配置文件中有一个标签import,它能把其它的bean定义配置文件导入到父文件夹中 4.通过FileSystemXmlApplicationContext FileSystemXmlApplicationContext的构造函数是一个字符串数组这个数组就是保存配置文件的路径