I'm using version 1.0.0.RC1 of the Spring Cloud stack and I think I've run into an issue. The use case is that my configuration server is serving up an application.yml file that is intended to be the default for my applications. One entry in there is the Tomcat server port:
server:
contextPath: /
port: 8080
useForwardHeaders: true
Normally, I can override the port value either through the command-line, system variable or environment variable. When using the configuration server, that is not happening. I've watched things in the debugger and I've noticed that when org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration#insertPropertySources runs through its algorithm to decide the placement of the composite property source, it consults the remoteProperties variable. Seeing that, I adjusted my bootstrap.yml file so that I could convince the algorithm to add the composite property source to the end of the list instead of the front. As I watched things in the debugger, I realized that the remoteProperties variable does not consult the bootstrap.yml file, instead relying on the default values of org.springframework.cloud.bootstrap.config.PropertySourceBootstrapProperties. I see that the propertySources list does contain the values of my bootstrap.yml file so the values are available.
At the end of the day, I want to the ability to override configuration properties fetched from the configuration server with values I've specified locally.
If it helps, this is the current contents of my bootstrap.yml but I've tried many combinations to see if I can make things work so the combination below might not be a "legal" combination of values.
spring:
application:
name: example
cloud:
config:
allowOverride: true
failFast: true
overrideNone: true
overrideSystemProperties: true
uri: ${SPRING_CONFIG_URI:http://localhost:2020}
Moving bootstrap.yml won't get moved to the front. I think you can setup env or sys properties to override, not sure the properties. Not in front of computer.
The remote property sources take precedence by default (this is by design, and nothing changed in 1.1). If you need to override a value in the remote application.yml you can do it on the command line, or with a remote config file that is specific to your app. Alternatively you can set things like spring.cloud.config.allowOverride=true in your remote application.yml (if I'm following what you wrote, you put it in bootstrap.yml which isn't going to help - an app can't decide on its own that it can override configuration from the remote source). (N.B. this is not a spring-cloud-config feature, it's in spring-cloud-context in the commons project.)
Documentation change: f29198b
Thanks. I've gotten things working. Here is my final solution:
# shared application.yml
spring:
cloud:
config:
allowOverride: true
failFast: true
overrideNone: false
overrideSystemProperties: false <---- this has to be false
#bootstrap.yml
spring:
application:
name: example
cloud:
config:
uri: ${SPRING_CONFIG_URI:http://localhost:2020}
Hi , I have seen three related issue, but still confused.
spring:
cloud:
config:
allowOverride: true
failFast: true
overrideNone: false
Where three properties should be set?
application.properties file on spring cloud server side or client side or remote git repository?
From #651 , I set them in application.yml on server side, but don't work.
From here, it looks like set in application.yml on remote git, and I try again, also not work, hope you could give me some help, thanks.
@allenyu5 Maybe you miss the property: spring.cloud.config.overrideSystemProperties=false. And the other properties leave the default value. I set it in remote git repository and it works fine.
More detail, see PropertySourceBootstrapProperties
@lowzj Thank you for your reminder, and I set
spring:
cloud:
config:
allowOverride: true
overrideNone: true
overrideSystemProperties: false
in remote git repo. It works this time, thanks for your help~
Most helpful comment
Thanks. I've gotten things working. Here is my final solution: