如何在Spring JUnit中配置WEB-INF / spring / webmvc-config.xml测试正确

时间:2012-01-10 12:18:21

标签: java spring testing maven

我有一个基于maven的Spring 3.0项目。 Web应用程序的Spring配置文件位于/<proj>/src/main/webapp/WEB-INF/spring/webmvc-config.xml

现在我想要一个JUnit测试来检查是否可以启动上下文。但我没有知道如何以maven正确的方式在@ContextConfiguration标签中指定该文件的位置。

我在做:

@RunWith(SpringJUnit4ClassRunner.class)
@Transactional()
@ContextConfiguration({
    "classpath:META-INF/spring/application-context.xml",
    "file:src/main/webapp/WEB-INF/spring/webmvc-config.xml",
})
public class SpringMvcContextTest {

但我很确定我不应该引用maven src目录。

1 个答案:

答案 0 :(得分:4)

如果您在maven,为什么不为此选择resource目录,并使用classpah:file.xml

相关问题