zilcuanu
zilcuanu

Reputation: 3715

Observation on the priority order of application properties in Spring Boot

When using Spring Cloud config server, I have observed the below behavior. Please let me know, if my hypothesis is correct regarding the behavior.

  1. If the application-${env}.yaml/properties have the server.port property set, I cannot override the value, even by passing -Dserver.port
  2. If I do not inherit the property defined in the spring cloud config, then I will be able to provide the value inside the application.yaml/property of the application
  3. If the property is defined inside the application's application.property/yaml, I can override the value from the command line by passing the -Dserver.port option.

Is my assumptions right based on the above behavior.

Upvotes: 0

Views: 1105

Answers (1)

Kaz
Kaz

Reputation: 416

Yes, spring cloud config value can't overwrite by default . We can change to override with property pring.cloud.config.allowOverride=true

https://cloud.spring.io/spring-cloud-static/spring-cloud.html#overriding-bootstrap-properties

Upvotes: 1

Related Questions