The class SystemEnvironmentPropertySource already supports lookup of properties from environment variables using the rules defined in SystemEnvironmentPropertySource.resolvePropertyName.

Example: A property with the name some.property=value with be resolved when defined as an environment variable SOME_PROPERTY=value.

In Spring Boot slightly different rules are used for resolving properties from environment variables, see Binding from Environment Variables.

The rules are: 1. Replace dots (.) with underscores (_). 2. Remove any dashes (-). 3. Convert to uppercase.

The second rule is causing a different result for values with dashes: * Spring: property.first-second=value will resolve to PROPERTY_FIRST_SECOND=value * Spring Boot: property.first-second=value will resolve to PROPERTY_FIRSTSECOND=value

I'm aware that Spring and Spring Boot are two different frameworks, but for situations where a combination of both are used (as in some of our applications) it would be very handy to also support the Spring Boot rule (Remove any dashes (-)) in addition to the current implemented rules in Spring.

As a temporary solution I have overwritten StandardEnvironment.customizePropertySources and implemented an own SystemEnvironmentPropertySource with the additional rule.

I'd be happy to create a pull request if you agree with the change.

Comment From: snicoll

Thanks for the suggestion but the biding you're referring to is far more complex and applied to other property sources as well. Such an opinionated handling of the configuration is better served in Spring Boot.