I am working on a standalone Swing/Spring Boot application which will be deployed in a number of different environments. For that reason, i need Spring to load an external config file where the user will enter the database credentials. Everything works fine when i annotate my configuration class with and when i run it from Netbeans:
@PropertySource("classpath:config.properties")
In this case, the text file is fetched from the src/main/resources folder and the application can use the credentials to launch. My question concerns the packaged JAR file that will ultimately be deployed. Since the classpath is INSIDE the JAR, how are the users expected to be able to edit its content?
Is there a way for @PropertySource to point outside the packaged JAR, for example using an environment variable which I am totally willing to add as a requirement for the app to work?
As mentioned here you can use yml to get the external property:
Spring boot external configuration of property file
@PropertySource("file:${application_home}config.properties")//or specify yaml file