Reputation: 689
I have a third party library, that is being configured with the important-config.yaml file.
prop1: value1
prop2: value2(need to override)
prop3: value3
To refer to it I have the next line in application.properties:
important-config=classpath:important-config.yaml
There is a property in yaml-file that depends on environment where app is running. So I need to override
this property on startup. How can I do that?
Upvotes: 0
Views: 4009
Reputation: 18245
I can see three suitable variants to solve it:
java -jar app.jar --prop2="value2"
java -Dprop2="value2"-jar app.jar
Full informaiton you can find here http://www.baeldung.com/properties-with-spring
Absolute all properties are stored in Spring Environment
object. You should pay attention on full variable name, because depending on other setting your prop2 could be store in xxx.yyy.prop2.
Upvotes: 1