java - 自定义 PropertyPlaceholderConfigurer 不解析嵌入的属性值
问题描述
我有一个 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}")
, 实际上是从属性源读取的原始值注入的,而没有我的自定义处理。
解决方案
经过一些调试后,我发现我也应该覆盖com.ec.survey.security.SafePasswordPropertyPlaceholderConfigurer#resolvePlaceholder
推荐阅读
- laravel - Laravel 5.7/6.x 的 PhpDocumentor
- android - 使用 Retrofit 2 上传对象数组中的文件
- html - Font Awesome 5:某些 unicode 不会在 html 选择中显示
- regex - Nginx location's regex, is escaping the forward slash needed?
- html - 使用 ngModel,禁用 html 选项默认选择
- linux - On OpenConnect VPN, Docker containers have DNS but host machine does not
- java - Disk Free decrease in a directory containing only live lucene indexes
- spark-ar-studio - How to convert screen boundaries to local coordinates in Spark AR?
- grid - ExtJs 6:如何通过已知位置直接获取特定网格单元组件
- node.js - 将缓冲区转换为十六进制字符串