Reputation: 764
.I have a project that has a spring-config.xml file in src/main/webapp/WEB-INF
and an applicationContext.xml file in src/test/resources
. I also have an abstract test base class for my unit tests in src/test/java
looks something like:
@ContextConfiguration(locations = {"classpath:/applicationContext.xml"})
public abstract class AbstractTestBase extends AbstractTransactionalJUnit4SpringContextTests {
//Common code and fields
}
All my unit tests extends this AbstractTestBase which points to the context within the src/test/resources
or should. The problem arises when running my unit tests it is pulling in the spring-config.xml file.
There are other projects my team is working on that have the same file structure, same app context setup, and run as intended, but even when I have each file in the project side by side I don't see where their file runs and this one doesn't.
I am new to spring so I don't know what it is I should be looking for.
Are there any situations where Spring or Maven would not take the app context I'm handing it given all files exist? Is there anything I might be missing?
EDIT: corrected to reflect that one file is a spring-config file.
Upvotes: 0
Views: 1205
Reputation: 21081
"classpath:/applicationContext.xml"
should look under src/test/resources
.
But it should be noticed that using that syntax will load the first one it finds and then stop as mentioned by '@chrylis'.
I once had similar problem.
You must have been using an IDE. There must have been applicationContext.xml
file in your target/test-classes/ (in Eclipse IDE)
in your project directory that is a copy of your xml file under src/main/webapp/WEB-INF
or xml file like it.
Upvotes: 1