I'm working on a project and have a use case where I need to provide application.properties file for Spring Boot from outside the JAR.
According to Baeldung, the priority order for picking up the application.properties is
- A /config subdirectory of the current directory
- The current directory
- A classpath /config package
- The classpath root
The issue with first two is I'll need to navigate to the directory containg the configs to run the JAR. It sounds no issue when working on local but wont be a feasible solution when deploying on remote hosts as through CI/CD frameworks.
I'm trying to find a mechanism using classpaths and avoid using spring boot's command line options mentioned over here or setting up environment variables.
I'm unable to figure out how to setup classpath while running FAT JAR and specify configs all together. If you can, please help me figure it out!
Thanks in advance :)
EDIT : I understand there are ways to achieve this using Spring Boot's command line options such as spring.config or loader.path etc.
I was trying to find a more implicit solution based on classpath and directory structures only to make it less coupled with the fact that Spring Boot is being used.