Reputation: 7219
I'm placing applicationContext.xml
in the same directory and package as my Java classes.
Doing the following to read it:
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
Yet I am consistently met with:
IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException
Which I do not get: The file is there, in the same directory as the classes. They're even compiled to /out
and I can see it's all there.
I've tried putting it in src/resources/applicationContext.xml
but to no avail.
Upvotes: 3
Views: 7906
Reputation: 11
I resolved this problem, as changing
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
to
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("packagename/applicationContext.xml");
My XML
file also resides in the same package as my java classes exist.
Upvotes: 0
Reputation: 48005
Spring will look for it in the root of the classpath ...
src/resources
is not on your classpath at allIf you put it in src/main/resources
then it will be (1) on your classpath and (2) in the root of your classpath.
Upvotes: 8