Using Spring 2.4.4 current profile structure is as follows:

|resources
|    |config
|    | --application-dev.properties
|    | --application-test.properties
|--application.properties
|--application-test.properties
|--application-prod.properties

Expected behavior: When the spring.profiles.active property uses a value equal to the current active profile, an InvalidConfigDataPropertyException is thrown.

Observed behavior: In application.properties, spring.profiles.active has the value default, dev and no exception is thrown even though the application.properties acts as the default profile.

In addition, if spring.profiles.active is set to dev in application.properties and set to default in application-dev.properties, an exception IS thrown.

Comment From: wilkinsona

When the spring.profiles.active property uses a value equal to the current active profile, an InvalidConfigDataPropertyException is thrown.

Can you please explain where this expectation comes from? The validity of spring.profiles.active isn't affected by its value, but by where it's used. It is invalid to use it in a profile-specific configuration file. This is described on the wiki but isn't really covered in the reference documentation. I've opened https://github.com/spring-projects/spring-boot/issues/25849 to improve the situation.

application.properties isn't a profile-specific configuration file so using spring.profiles.active in application.properties is valid.

application.properties acts as the default profile

application.properties isn't profile-specific. With the default profile active, application-default.properties would be the profile-specific file.

In addition, if spring.profiles.active is set to dev in application.properties and set to default in application-dev.properties, an exception IS thrown.

The exception is thrown because spring.profiles.active has been used in the profile-specific application-dev.properties file.

Comment From: JMartinetti20

Ah, thanks for the clarification with the wiki. The reason for the exception does make sense now after reading it. It is not throwing the exception for duplicate active profiles, it's because 2.4 now throws the exception when spring.profiles.active is used in a profile-specific property file. I'm usually looking at the documentation page more so that could be why I missed it.

Comment From: wilkinsona

Great. Thanks for getting back to us. I'll close this one in favour of #25849 which we'll use to improve the reference documentation.