ApplicationContext context = new ClassPathXmlApplicationContext(
new String[] {"services.xml", "daos.xml"});
当前的*.xml文件路径是相对于WEB-INF/class路径
如果配置文件在WEB-ROOT目录下的话可以用
ApplicationContext context = new FileSystemXmlApplicationContext(
new String[] { "WebRoot/frameworkconfig/springframeworkconfig.xml" });
Spring框架配置文件加载方式
本文介绍了Spring框架中两种常见的配置文件加载方式:通过ClassPathXmlApplicationContext加载位于WEB-INF/classes路径下的配置文件,以及通过FileSystemXmlApplicationContext加载位于WEB-ROOT目录下的配置文件。
1381

被折叠的 条评论
为什么被折叠?



