Ant:找不到我的@ContextConfiguration

发布于 2024-12-20 02:01:22 字数 425 浏览 6 评论 0原文

我们有一个 Spring 3 MVC 应用程序和用于 spring 控制器的 JUnit 测试用例。 Junit版本是4.8.1,支持ContextConfiguration注释。

以下是我在测试存根中添加上下文配置的方法

@ContextConfiguration(locations = "file:WebContent/WEB-INF/myappconfig.xml")

,我能够在本地运行 junit,但是当我尝试使用 ant 构建脚本运行它时,它会抛出错误 java.lang.IllegalStateException: Failed to load ApplicationContext

我尝试将 classpath 元素设置为 WebContent,然后设置为 web-inf,但没有任何效果。

We have a Spring 3 MVC application and JUnit test cases for spring controllers. The Junit version is 4.8.1 which supports ContextConfiguration annotation.

Here is how I am adding context configuration in my test stub

@ContextConfiguration(locations = "file:WebContent/WEB-INF/myappconfig.xml")

I am able to run the junits locally, but when I am trying to run this with my ant build script, it throws an error java.lang.IllegalStateException: Failed to load ApplicationContext

I tried to set classpath element to the WebContent, then upto web-inf, nothing works out.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光与爱终年不遇 2024-12-27 02:01:22

我正在使用

@ContextConfiguration({ "classpath*:application-test.xml" })

,我的 application-test.xml 位于 main/resources 下

i'm using

@ContextConfiguration({ "classpath*:application-test.xml" })

and my application-test.xml resides under main/resources

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文