question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bootstrap.yml not being respected when establishing property source ordering

See original GitHub issue

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}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
kurroncommented, Mar 28, 2016

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}
0reactions
allenyu5commented, May 9, 2017

@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~

Read more comments on GitHub >

github_iconTop Results From Across the Web

bootstrap.yml not loading in Spring Boot 2 - Stack Overflow
The file bootstrap.yml is being ignored when starting the application. POM Client <parent> <groupId>org.
Read more >
Config file processing in Spring Boot 2.4
Document Order. Starting with Spring Boot 2.4, there will be a simple rule that can be applied when loading properties and YAML files....
Read more >
Microservices with Spring Cloud Kubernetes Reference ...
Discovering services across all namespaces using the Spring Cloud DiscoveryClient; Using ConfigMap and Secrets as Spring Boot property sources with Spring ...
Read more >
Management & Monitoring - Micronaut Documentation
If the requested bean type does not implement Ordered, Micronaut searches for ... Configuration can by default be provided in Java properties, YAML,...
Read more >
Spring Configuration Bootstrap vs Application Properties
We use application.yml or application.properties for configuring the application context. When a Spring Boot application starts, it creates an ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found