I have service that was using Spring Boot 2.4.1 For local development I have local profile and activate it using

application.yml:

spring:
  profiles:
    active: local

application-local.yml:

spring:
  config:
    activate:
      on-profile: local

After upgrading to Spring Boot 2.4.2 my application doesn't start with error

org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property 'spring.config.activate.on-profile' imported from location 'class path resource [application-local.yml]' is invalid in a profile specific resource [origin: class path resource [application-local.yml] - 4:19]
    at org.springframework.boot.context.config.InvalidConfigDataPropertyException.lambda$throwOrWarn$1(InvalidConfigDataPropertyException.java:121)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1087)
    at org.springframework.boot.context.config.InvalidConfigDataPropertyException.throwOrWarn(InvalidConfigDataPropertyException.java:118)
    at org.springframework.boot.context.config.ConfigDataEnvironment.checkForInvalidProperties(ConfigDataEnvironment.java:349)
    at org.springframework.boot.context.config.ConfigDataEnvironment.applyToEnvironment(ConfigDataEnvironment.java:318)
    at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:231)
    at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:97)

Should it somehow be changed or is this is a 🐛 ?

Thanks in advance

Comment From: wilkinsona

The exception being thrown is due to #24733. Prior to that change the property was silently ignored when it was used in a profile-specific file.

You don't need to set spring.config.activate.on-profile to local in application-local.yml as the whole file is already activated when the local profile is active.

Comment From: wilkinsona

While spring.profile.activate.on-profile wasn't necessary in this case, it could be used in a profile-specific file in Spring Boot 2.4.1. I was incorrect when I said above that the property was silently ignored. #24990 is now tracking this change in behaviour. It includes an example that can't be addressed by removing the use of the property as could be done here.