After using spring boot 2.4.4, updated YMLs to use spring.config.activate.on-profile instead of spring: profiles. This is causing properties to be inherited incorrectly.

#common section
#only one variable example - we have more entries in common section
server.port: ${PORT:8080}


spring.config.activate.on-profile: development-cloud

spring.config.activate.on-profile: uat
#override
server:
 port: 10105

spring.config.activate.on-profile: uat-cloud

When running application with spring.profiles.active=uat-cloud profile we expect that server.port will be 8080 (inherited from common section) but in fact it became 10105 (somehow taking it from uat profile).

Apart from using spring.config.use-legacy-processing, how we can get previous behaviour (based on 2.3) when we "inherit" "common" section in uat-cloud profile and override only certain params.

Comment From: wilkinsona

Your YAML doesn't appear to be correctly formed. The --- document separators are missing. This YAML works for me:

server:
  port: ${PORT:8080}

---
spring:
  config:
    activate:
      on-profile: development-cloud

---
spring:
  config:
    activate:
      on-profile: uat
server:
 port: 10105

---
spring:
  config:
    activate:
      on-profile: uat-cloud

When the uat-cloud profile is active the port is 8080. It's only when the uat profile is active that the port changes to 10105.

I'm going to close this issue as the problem appears to be user error. If that's not the case and you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue. Once we have a minimal sample that reproduces your problem, we can re-open this issue and take another look.