Tuesday

Spring - applicationContext.xml cannot be opened because it does not exist


BUG:
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

private static final ClassPathXmlApplicationContext factory = new ClassPathXmlApplicationContext("applicationContext.xml");

ClassA classA = (ClassA)factory.getBean("ClassA");

FIX:
You should keep your spring files in source folder. (src, resources vs.) WEB-INF is not a source folder.
Move your applicationContext.xml file in a sub-folder of the src folder.




No comments:

Post a Comment