I'm trying to externalize a properties file. Right now, I'm testing by placing my properties file under my user profile folder, but I'm getting a NullPointerException
. To be more specific, the System.out.println
statement isn't being displayed in the console, which leads me to think that maybe it's the environment variable that's triggering the NullPointerException
. I have also ensured that I placed the properties file in the correct path. Here is part of the code:
@PropertySource("file:${USERPROFILE}/test.properties")
public MyClass{
private static Environment e;
public static void main(String[] args){
System.out.println("Test properties file: " + e.getProperty("myKey");
}
}
Properties file:
myKey=testvalue
And this line in my dispatcher servlet xml file :
<context:property-placeholder location="classpath*:query.properties, file:${USERPROFILE}/test.properties"/>
Where am I going wrong here? Any help would be greatly appreciated.