I have a spring boot application which is working fine when server field values are put in application.properties and read. But, my application can have dynamic server values. So, while running java -jar your-app.jar server nam
application will take all properties for nam server, java -jar your-app.jar server euro
will take all properties for euro server. How can I achieve this.
I was thinking of two files application.nam.properties and application.euro.properties and pass that java -jar your-app.jar --spring-config-location=file:///application.euro.properties
You can use active profiles to accomplish this. In your example you would have an application-nam.properties
and an application-euro.properties
. The euro properties would be activated using --spring.profiles.active=euro
. You could set any common properties directly in application.properties
.
Documentation can be found here