spring-cloud / spring-cloud/spring-cloud-consul
can't use system properties to override configuration in consul
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 822
- Forks
- 539
- Avg merge
- 9h 31m
- Merged PRs (30d)
- 7
Description
I'm using spring could consul 1.3.2.release version.
Here is my bootstrap.yml:
spring:
application:
name: myApp
cloud:
config:
allow-override: true
override-system-properties: false
override-none: false
consul:
host: localhost
port: 8500
config:
enabled: true
with configuration when I passed -Dmy.prop=system the parameter for my java application, the application still get my.prop from instead of the command line.
I debugged the PropertySourceBootstrapConfiguration source in insertPropertySources method, it seems that spring cloud create new PropertySourceBootstrapProperties with default value in code, it doesn't get the configuration from bootstrap.yml:
private void insertPropertySources(MutablePropertySources propertySources,
CompositePropertySource composite) {
MutablePropertySources incoming = new MutablePropertySources();
incoming.addFirst(composite);
PropertySourceBootstrapProperties remoteProperties = new PropertySourceBootstrapProperties();
new RelaxedDataBinder(remoteProperties, "spring.cloud.config")
.bind(new PropertySourcesPropertyValues(incoming));
if (!remoteProperties.isAllowOverride() || (!remoteProperties.isOverrideNone()
&& remoteProperties.isOverrideSystemProperties())) {
propertySources.addFirst(composite);
return;
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with bootstrap.yml and the PropertySourceBootstrapConfiguration.insertPropertySources entry point shown in the report. Trace how spring.cloud.config properties are bound to PropertySourceBootstrapProperties, then verify that the command-line system property overrides the Consul value when configured; add or update a regression test if the project provides one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100