We want to automatically pick property file based upon mentioned the profile name in spring.profiles.active
and the path in -Dspring.config.location
application-dev.properties
If we are running jar in Unix OS then we have to use /
at the end of -Dspring.config.location
otherwise it will give below error.
Error :: java.lang.IllegalStateException: File extension of config file location 'file:/home/xyz/projectName/cfg' is not known to any PropertySourceLoader. If the location is meant to reference a directory, it must end in '/'
java -Dspring.profiles.active=dev -Dspring.config.location=/home/xyz/projectName/cfg/ -jar /home/xyz/project/abc.jar
or
java -jar /home/xyz/project/abc.jar --spring.profiles.active=dev --spring.config.location=/home/xyz/projectName/cfg/