2
votes

I have a webapp which I deploy on a Jetty server through jetty runner. I inject properties read through a properties file using Spring. As of now, I have kept the properties file within the webapp itself (in WEB-INF/classes) directory. I want to keep this properties file external to the webapp and then inject them using Spring. Is there any configuration in the jetty.xml file I can do so I can achieve this?

1

1 Answers

0
votes

I managed to solve this by adding the properties file as a command line parameter while starting jetty. Something like:

java -Dexternal.properties.file=myfile.properties -jar jetty.jar 

In java code, I read it by getting system property and then using FileUtils to get file.

String externalPropertiesFile = System.getProperty("extern.properties.file");
File file = FileUtils.getFile(externalPropertiesFile);