I saw some similar questions on this,but I don't understand them enough so i want to ask the question and tailor it my own way.
I have a properties file that I store in src/main/resources, and then reference this in my code like so:
Properties prop = new Properties();
InputStream input = null;
try {
input = new FileInputStream("src/main/resources/app.properties");
// load a properties file
prop.load(input);
this works locally, however when I create a .war file and deploy it to the sever it has no idea where the properties file is. Where do I put this properties file, and how do I reference it in the code, so that I can run it locally, and on the server without any problems?
I assume you have maven project, you can put that properties file at src/main/resources/app.properties and change the code to read it as
getClass().getClassLoader().getResourceAsStream("/app.properties");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With