Spring - applicationContext.xml cannot be opened because it does not exist
If you use maven, create a directory called resources
in the main directory, and then copy your applicationContext.xml
into it.
From your java code call:
ApplicationContext appCtx = new ClassPathXmlApplicationContext("applicationContext.xml");
You should keep your Spring files in another folder, marked as "source" (just like "src" or "resources").
WEB-INF is not a source folder, therefore it will not be included in the classpath (i.e. JUnit will not look for anything there).
I got the same error.
I solved it moving the file applicationContext.xml
in a
sub-folder of the src
folder. e.g:
context = new ClassPathXmlApplicationContext("/com/ejemplo/dao/applicationContext.xml");