I am trying to set the configuration location for my Project but I keep getting the following error:
java.io.FileNotFoundException: class path resource [main/resources/app-context.xml] cannot be opened because it does not exist
I have my project set up like this:
And I have my code set up as:
ApplicationContext context = new ClassPathXmlApplicationContext(configLocation: "main/resources/app-context.xml");
How can I fix this?
This question is related to
java
spring
file
intellij-14
The file location/path has to relative to your classpath locations. If resources directory is in your classpath you just need "app-context.xml" as file location.
We can also try this solution
ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath*:app-context.xml");
in this the spring automatically finds the class in the class path itself
Try this:
ApplicationContext context = new ClassPathXmlApplicationContext("app-context.xml");
Source: Stackoverflow.com