0

我有以下@ConfigurationProperties属性持有者:

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

    private String name;
}

我的 application.properties 看起来像这样:

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

remove.service.name是在运行时收到的环境变量。

但是,如果remote.service.name未提供,则值为EtlConfigurationHolder.namestring "${remote.service.name}"

如何使属性返回 null 而不是这个占位符字符串?

4

1 回答 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/

于 2022-01-28T08:41:01.410 回答