繁体   English   中英

为什么ContextConfiguration位置在思想和日食上有所不同

[英]Why is ContextConfiguration location different in idea and eclipse

在我们的团队中,我们同时使用Eclipse和Idea。 效果很好,除了一个小问题,我不知道如何解决。 在我们的测试中设置ContextConfiguration位置并在Eclipse中运行它们时,所有内容都像一个超级按钮:

@Test(groups = { "database" })
@ContextConfiguration(locations = {" file:src/main/webapp/WEB-INF/applicationContext.xml" })

但是在我的Idea env中,出现“找不到applicationContext”错误。 我需要像这样设置位置(项目名称是services):

@Test(groups = { "database" })
@ContextConfiguration(locations = {" file:services/src/main/webapp/WEB-INF/applicationContext.xml" })

项目结构是这样的:带有两个子poms的parent.pom:services.pom和other.pom。 当像这样从服务项目在终端中运行测试时:

mvn -Dtest=com.mytest.service.somepackage.TheTest test 

没有问题。 我猜想因为我的项目结构是有两个孩子的父母,所以需要/ service(该项目是通过指出父pom创建的)。 有没有办法解决这个问题? 您能帮我解决一个问题吗? 谢谢

您使用相对于当前工作目录的路径。 Eclipse和Idea使用不同的目录。 尝试使用类路径位置:

@ContextConfiguration(locations = {" classpath:/WEB-INF/applicationContext.xml" })

但是我不确定您的类路径配置。 通常, src/main/webapp将被复制到目标webapp目录。 可能是您需要对其进行配置以包含目标webapp目录。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM