Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 具有资源值的SpringJUnit4ClassRunner上下文配置_Java_Spring_Junit Runner_Spring Boot Test - Fatal编程技术网

Java 具有资源值的SpringJUnit4ClassRunner上下文配置

Java 具有资源值的SpringJUnit4ClassRunner上下文配置,java,spring,junit-runner,spring-boot-test,Java,Spring,Junit Runner,Spring Boot Test,我正在尝试配置Spring、Junit和Hibernate(为我们的测试用例启用@Autowire注释)。我当前的设置是: @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @ContextConfiguration({ "file:src/main/webapp/WEB-INF/applicationContext.xml", "file:src/main/webapp/WEB-INF/di

我正在尝试配置Spring、Junit和Hibernate(为我们的测试用例启用
@Autowire
注释)。我当前的设置是:

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration({
        "file:src/main/webapp/WEB-INF/applicationContext.xml",
        "file:src/main/webapp/WEB-INF/dispatcher-servlet.xml",
})
public class UserManagementServiceTest {...}
但是,初始化失败,原因是

Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
我们在
context.xml
文件中定义了各种凭证,这些凭证是tomcat在运行应用程序时获取的。结构如下

<Context>
    <Resource name="abc/abcManager"
                auth="Container"
                type="path.to.file"
                factory="org.apache.naming.factory.BeanFactory"
                attr1="asas"
                attr2="asda"/>
</Context>
java.lang.IllegalStateException: Failed to load ApplicationContext
...
Caused by: org.xml.sax.SAXParseException; lineNumber: 19; columnNumber: 10; cvc-elt.1: Cannot find the declaration of element 'Context'.