【问题标题】:Custom PropertyPlaceholderConfigurer doesn't resolve embedded property values自定义 PropertyPlaceholderConfigurer 不解析嵌入的属性值
【发布时间】:2020-05-06 16:25:07
【问题描述】:

我有一个 Spring 4.3 自定义 PropertyPlaceholderConfigurer,它在注入之前对从属性文件中读取的值进行额外处理:

public class MyPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer{ 

    @Override
    protected String convertPropertyValue(final String originalValue) { ... }

    @Override
    protected String resolveSystemProperty(final String key) {
       return convertPropertyValue(super.resolveSystemProperty(key));
    }
}

我的问题是注解注入属性值的 bean 字段,例如。 @Value("${some_property}"),实际上是从属性源读取的原始值注入的,没有经过我的自定义处理。

【问题讨论】:

    标签: java spring property-placeholder


    【解决方案1】:

    经过一些调试,我发现我也应该覆盖com.ec.survey.security.SafePasswordPropertyPlaceholderConfigurer#resolvePlaceholder

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-03
      • 2023-03-04
      • 1970-01-01
      • 2015-08-10
      相关资源
      最近更新 更多