Let's suppose I have a application.yml file put just next to my jar. This file looks like


spring:
  application:
    name: test-app
---
spring:
  config:
    activate:
      on-profile: production

some:
  default:
     value: ${SOME_DEFAULT_VALUE:false}

--- 
spring:
  config:
    activate:
      on-profile: config-server
    import: "configserver:"
  cloud:
    config:
      enabled: true
      uri: http://config-server.uri/config

and my config server serves a file named test-app-extra-profile.yaml containing

some:
  default:
     value: true

Starting application without legacy processing, with profiles production,config-server,extra-profile results in some.default.value valued to false. I would have expected the contrary due to that

According to documentation,

Imports can be considered as additional documents inserted just below the document that declares them

If so why my application keeps seeing value to false?

Naive question: why isn't the import inserted directly in the section that declares it?

For example, the process of property loading could be

  • crawl application.yml and for each import, resolve its properties and insert it
  • crawl the resolved application.yml according to the law The later in the document the stronger.

After watching the following discussion, I would have expected this behaviour

Comment From: antechrestos

I found the issue that was on my side: my property was valued with a reference to an environment variable named as the property. As property can be valued from an environment variable and that it takes precedence, spring will value spring.default.value to SPRING_DEFAULT_VALUE environement variable no matter what will be the local or remote property values.

Comment From: wilkinsona

Thanks for letting us know, @antechrestos.