I'm new to Linux, Java, and Apache Commons Configuration and am having issues locating a properties file between environments.
I'm building a Spring API with Maven on Windows and have a .properties
file i want to pull settings from. I also am trying to publish this API to a Linux based Docker container and am confused about the file location strategies.
Everything works on Windows with the properties file in C:\users\myusers\app.properties
. On the Linux container, i have both my jar and properties file here /usr/bin/myapp
but I am unsure how to use any of the strategies to access both, as this fails in Docker/Linux.
Is there a best practice on where i should store the properties file in the container?
CombinedLocationStrategy strategy = new CombinedLocationStrategy(
Arrays.asList(new HomeDirectoryLocationStrategy(), new FileSystemLocationStrategy()));
Parameters params = new Parameters();
FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
.configure(params.fileBased()
.setLocationStrategy(strategy)
.setFileName("app.properties"));
Configuration propConfig = builder.getConfiguration();
rootDirectory = propConfig.getString("rootfolder");