'@ConfigurationProperties returns property placeholder instead of null

I have the following @ConfigurationProperties property holder:

@ConfigurationProperties(prefix = "custom.service")
public class CustomServicePropertyHolder {

    private String name;
}

and my application.properties looks like this:

custom.service.name=${remote.service.name}
custom.service.....=...
custom.service.....=...

remove.service.name is an environment variable received in the runtime.

However, when remote.service.name was not provided, the value of the EtlConfigurationHolder.name is a string "${remote.service.name}".

How to make the property to return null instead of this placeholder string ?



Solution 1:[1]

I also encountered such a problem ... And it has been present for a long time

I found only one place where at least some solution is attached

https://davidagood.com/spring-boot-fail-on-missing-env-vars/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 LeshaRB