开发者

Why is ContextConfiguration location different in idea and eclipse

In my team we work both in Eclipse and Idea. That works pretty good, except for one minor issue that I can't figure out how to solve. When setting the ContextConfiguration location in our tests and running them inside Eclipse everything works like a charm:

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

But in my Idea env I get "could not find applicationContext" error. I need to set the location like this(project name is services):

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

The project structure is like this: parent.pom with two child poms: se开发者_高级运维rvices.pom and other.pom. When running the test in the terminal from the service project like this:

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

there are no issues. I guess that since my project structure is parent-with-two-children the need of /service is necessary(The project is created by pointing out the parent pom). Is there a way to fix this? Could you please help me with a solution. thx


You use a path relative to the current working directory. Eclipse and Idea use different directories. Try to use a classpath location:

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

But I'm not sure about your classpath configuration. Typically the src/main/webapp will be copied to a target webapp directory. May be you need to configure it to contain the target webapp dir.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜