Java JUnit错误:加载ApplicationContext失败:有问题的资源:类路径资源

Java JUnit错误:加载ApplicationContext失败:有问题的资源:类路径资源,java,spring,junit,applicationcontext,Java,Spring,Junit,Applicationcontext,我一直在尝试在Junit中配置应用程序上下文,如下所示: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "../application.xml") public class TestClass{ ..... } 运行JUnit时出现的错误是: java.lang.IllegalStateException: Failed to load ApplicationContext

我一直在尝试在Junit中配置应用程序上下文,如下所示:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "../application.xml")
public class TestClass{
.....
}
运行JUnit时出现的错误是:

java.lang.IllegalStateException: Failed to load ApplicationContext
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: class path resource [application.xml]

你知道哪里有问题吗?

检查你的
应用程序。xml
从以下内容开始:


...

您不能使用相对文件路径格式。使用正确的基于类路径的路径(例如,将你的
application.xml
放在
src/main/resources
中,只需说
locations=“application.xml”
)。@chrylis小心地选择-我想这不是问题所在。它能够找到application.xml文件。但是当它读到它的时候,有一个问题pls@DineshDonthaSpring版本是4.1.5Use@ContextConfiguration(“/application.xml”)。如果没有工作,请张贴您的项目结构。我的application.xml出错了