In my java app there is a code which reads the properties file from src/main/resources folder.
Now I need to create a jar file and also remove the properties file from src/main/resources folder and place it outside the jar file(in the same location as jar file) so that data inside it can be changed easily in future.Code:@Component("mailerProperties") public class MailerProperties { private static Properties properties; public MailerProperties() { properties = new Properties(); InputStream inStream; try { inStream = (new ClassPathResource("mailer.properties")).getInputStream(); properties.load(inStream); } catch (IOException e) { e.printStackTrace(); } } public String getValue(String key) { return properties.getProperty(key); } }
Question: Currently it uses ClassPathResource("mailer.properties") to read the prop file. What change I need to make to read it from outside the jar file


Reply With Quote