Why is ContextConfiguration location different from idea and eclipse

On my team, we work in both Eclipse and Idea. This works pretty well, except for one minor issue that I can't figure out how to solve. When you set the location of the ContextConfiguration in our tests and run them inside Eclipse, everything works like a charm:

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

      

But in my env idea I am getting the error "could not find applicationContext". i need to set location like this (project name - services):

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

      

The project structure is as follows: parent.pom with two child pumps: services.pom and other.pom. When running a test in a terminal from a service project, do the following:

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

      

no problem. I am assuming that since my project structure is a parent with two children, a need for / service is needed (the project is created by specifying the parent pump). Is there a way to fix this? Could you please help me with a solution. THH

+2


a source to share


1 answer


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

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

      



But I'm not sure about your classpath configuration. src/main/webapp

Will usually be copied to the target webapp directory. Maybe you need to configure it to contain the target address of the web manager.

+5


a source







All Articles