Spring Junit测试用例,如何读取web.xml
我试图在测试用例中使用web.xml。但是,我不能Spring Junit测试用例,如何读取web.xml,spring,junit,web.xml,Spring,Junit,Web.xml,我试图在测试用例中使用web.xml。但是,我不能 @ContextConfiguration(locations={"file:src/main/webapp/WEB-INF/web.xml", "/integration/restful/*.xml"} public class RestfulTest { } 错误消息: Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingE
@ContextConfiguration(locations={"file:src/main/webapp/WEB-INF/web.xml",
"/integration/restful/*.xml"}
public class RestfulTest { }
错误消息:
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://java.sun.com/xml/ns/javaee] Offending resource: URL [file:src/main/webapp/WEB-INF/web.xml]
web.xml的标题:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
我能做什么?@ContextConfiguration正在查找Spring应用程序上下文配置文件。xml不是Spring配置文件,而是在servlet容器中配置web应用程序的文件 Spring应用程序上下文文件描述您的Spring托管bean和依赖项。见: 测试失败,因为Spring正在尝试根据Spring应用程序上下文文件的模式解析web.xml文件