【问题标题】:How to WEB-INF/spring/webmvc-config.xml configuration in Spring JUnit Tests correct如何在 Spring JUnit 测试中正确配置 WEB-INF/spring/webmvc-config.xml
【发布时间】:2012-01-10 12:18:20
【问题描述】:

我有一个基于 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 目录。

【问题讨论】:

    标签: java spring testing maven


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-06
      • 1970-01-01
      • 1970-01-01
      • 2017-07-08
      • 1970-01-01
      • 1970-01-01
      • 2018-08-07
      • 1970-01-01
      相关资源
      最近更新 更多