【问题标题】:@ConfigurationProperties returns property placeholder instead of null@ConfigurationProperties 返回属性占位符而不是 null
【发布时间】:2022-01-28 16:41:01
【问题描述】:

我有以下 @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.name 的值是一个字符串"${remote.service.name}"

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

【问题讨论】:

  • 我也遇到过这种行为...我现在无法添加 NotNull 验证

标签: spring-boot properties placeholder configurationproperties


【解决方案1】:
猜你喜欢
  • 2015-05-23
  • 2014-12-20
  • 2012-12-27
  • 2013-11-03
  • 2015-09-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-28
相关资源
最近更新 更多