Changing the directory from which ClassLoader looks in for Web Application
The web application I am working on uses a certain resource. For testing purposes, I want it to use a different resource with the same name but in different directory. I use classloader to load the resources. Currently it always loads the resource from the test/resources directory. I want to be able to tell it to be able to get it from a different directory (when not testing) without changing the code.
This is how I used ClassLoader:
ClassLoader loader = Thread.currentThread().getContextClassLoader();
InputStream file =loader.getResourceAsStream("resource.xml");
So, when I deploy the web-app (jetty container), I need to also modify something or somehow give it a different classpath or place to look since I have resources that are different for test开发者_运维技巧ing and the main use.
精彩评论