【发布时间】:2013-12-17 08:24:54
【问题描述】:
我正在使用 spring-PropertySourcesPlaceholderConfigurer 公开的最新属性加载机制,并尝试即时解密加密的属性。请问PropertyPlaceholderConfigurer 可以覆盖resolvePlaceholder,并为其添加解密机制。
但是,我不知道如何在 PropertySourcesPlaceholderConfigurer 中执行此操作。已尝试覆盖 processProperties,并传入我的自定义 ConfigurablePropertyResolver[with getProperty Overriden],但这不起作用。
MutablePropertySources propertySources = new MutablePropertySources();
try {
propertySources.addFirst(getExtendPortsProperties());
propertySources.addFirst(new ResourcePropertySource("classpath:/X.properties"));
propertySources.addFirst(new ResourcePropertySource("classpath:/Y.properties"));
} catch (IOException e) {
throw new RuntimeException("failed to read property source", e);
}
这就是我阅读属性的方式。然后,
PropertySourcesPlaceholderConfigurer result = new PropertySourcesPlaceholderConfigurer();
result.setPropertySources(firePropertiesSources);
这就是我设置属性的方式。
现在,这些 props 中的属性之一已加密,我需要指示 Spring 在用实际值替换占位符之前对其进行解密。[我需要指定我的自定义实现]
【问题讨论】:
标签: java spring encryption properties