Issue
I have this scenario where I need to load properties file according to the server name.
I have resource
in this structure.
I have 2 different servers. let say SERV-A and SERV-B and each of these servers have their sperate e1, e2 servers. eg.. SERV-A-e1, SERV-A-e2, SERV-B-e1, SERV-B-e2
. The code base is same.
resource - |
|-SERV-A - |
|-application.properties
|-application-e1.properties
|-application-e2.properties
|-SERV-B - |
|-application.properties
|-application-e1.properties
|-application-e2.properties
So I want that when I deploy my application on server SERV-A it should read application.properties and application-e1.properties files from resource/SERV-A
and when I deploy it on server SERV-B then it should read from resource/SERV-A
Solution
Thanks @Anton Belev.
I was able to resolve this situation.
I recreated my resource
structure.
resource - |
|----------
|-application.properties
|-application-SerA-e1.properties
|-application-SerA-e2.properties
|-application-SerB-e1.properties
|-application-SerB-e2.propertie
So now when I want to deploy on SERVER-A. I can simply give a simple java command and have it running with correct sets of properties.
java -jar -Dspring.profiles.active=SerA-e1 /path/to/jar/NameOFYourJar.jar &
Answered By - Akif
Answer Checked By - Senaida (JavaFixing Volunteer)