在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");