Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [com/main/beans.xml]; nested exception is java.io.FileNotFoundException: class path resource [com/main/beans.xml] cannot be opened because it does not exist
ApplicationContext context =
new ClassPathXmlApplicationContext("com/main/beans.xml");
I have tried before with
ApplicationContext context =
new FileSystemXmlApplicationContext("src/main/java/com/main/beans.xml");
And it works well.
How to do that relative to the classpath?
Note: classpath is in the build path
In the example I'm following, it has the following structure and it works
Project structure
Classpath
ApplicationContext context =
new ClassPathXmlApplicationContext("com/caveofprogramming/spring/test/beans/beans.xml");
src/main/resources
not in java. When compiling with maven the xml files are ignored if they aren't in resources (Unless you do some extra work to add them back). – M. Deinum