Reputation: 593
I am trying to load a file name SpringConfig.xml
from directory
resources\cfg\SpringConfig.xml
using the
context = new ClassPathXmlApplicationContext("/cfg/SpringConfig.xml")
which does not work, but the same thing if I change the location as resources\SpringConfig.xml
it does work fine with
context = new ClassPathXmlApplicationContext("SpringConfig.xml")
but I want to use the prior one, can someone help on how I fix this?
Upvotes: 0
Views: 401
Reputation: 240996
Try with
context = new ClassPathXmlApplicationContext("cfg/SpringConfig.xml")
Upvotes: 0
Reputation: 43177
Backslashes are special in Java. Try switching to forward slashes. (In fact, it shouldn't even compile with the backslashes in your example!)
Similarly, the initial slash should probably be omitted, as otherwise you're specifying an absolute rather than a relative path.
Upvotes: 1