Duplicating this here from Stackoverflow as I consider it to be an issue/bug.

Property expansion are not properly resolved when the property is binding using ConfigurationProperties. Or more specifically when the property being expanded isn't present, the binding doesn't fail and the property name is used as the value.

Let's look at the following scenario

// The binding class
open class MyProperties {
    lateinit var myValue: String
}

// The configuration
@Configuration
@EnableConfigurationProperties
class MyConfig {
    @Bean
    @ConfigurationProperties(prefix = "my.properties")
    fun myProperties(): MyProperties = MyProperties()
}
## The spring properties yaml
my.properties:
    my-value: ${my.another.value}

When the property my.another.value that is being expanded is present, then the value is present in MyProperties#myValue; however, when the property my.another.value is not present then the raw string "${my.another.value}" is loaded into MyProperties#myValue.

Is there a way to force the application into attempting to expand the property (and failing to startup) instead of using the expansion expression as the value?

Comment From: philwebb

Thanks for the report. You're not the first person that has raised this and we actually already have an issue open to add the feature (#18816). We've unfortunately not had the time to provide a solution yet.