Hello I have the following project structure.
I want to store my properties file outside my jar , so that if I change any property it will be reflected automatically. My property file contains ip of the other servers, which might change, so that's why I want to keep my properties file outside my jar.
My resources
folder contains all my properties file including application.propeties.
I am using following snippet to read from my properties file.
server_1 = new Properties();
server_1.load(PropertyReader.class.getClassLoader().getResourceAsStream("resources/server_1.properties"));
server_2 = new Properties();
server_2.load(PropertyReader.class.getClassLoader().getResourceAsStream("resources/server_2.properties"));
I have also tried
server_2.load(PropertyReader.class.getClassLoader().getResourceAsStream("server_2.properties"));
server_2.load(PropertyReader.class.getClassLoader().getResourceAsStream("/server_2.properties"));
But it gives me following error :
Caused by: java.lang.NullPointerException: null
I have gone through the this link so that's why I have created resources
folder at src
level still I am not able to understand this behaviour.
Thank you