java加载spring配置文件
来源:互联网 发布:张伯伦生涯场均数据 编辑:程序博客网 时间:2024/06/05 00:03
在junit中要初始化spirng的配置文件 可以用
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" });
如果是用jdk1.4版本,可能无法读取spring的xsd标签可以下载xerces-2_11_0.jar并且添加xercesImpl.jar,xml-apis.jar这2个包到classpath中,然后用,强制指定xml解析器
System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
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" });
如果是用jdk1.4版本,可能无法读取spring的xsd标签可以下载xerces-2_11_0.jar并且添加xercesImpl.jar,xml-apis.jar这2个包到classpath中,然后用,强制指定xml解析器
System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
0 0
- java加载spring配置文件
- java加载spring配置文件
- Java类中加载Spring配置文件步骤
- Spring配置文件加载外部配置文件
- spring配置文件加载
- spring多配置文件加载
- spring 加载配置文件
- Spring配置文件加载流程
- spring加载xml配置文件
- spring加载配置文件
- spring 配置文件加载方式
- spring配置文件加载流程
- 自定义加载Spring配置文件
- spring classpath 加载配置文件
- Spring:加载xml配置文件
- spring加载properties配置文件
- Spring加载配置文件
- Spring动态加载配置文件
- scrollview上的button
- jquery 遍历table中的超链接
- 分布式系统的事务处理
- Google广告AdMob的集成和使用
- android studio 2.2中进行ndk(c/c++)开发
- java加载spring配置文件
- 【转】mysql优化
- QAbstractTableModel 和委托的结合使用
- 2016 Unicode Conference拾遗(五)
- Web项目的WEB-INF目录使用说明以及重定向与转发
- 高精度加法
- 参数服务器代码解读(1)
- Spring事务理解-1
- 截屏工具类