+ -
当前位置:首页 → 问答吧 → spring怎么获得properties文件里面的数据?

spring怎么获得properties文件里面的数据?

时间:2011-11-24

来源:互联网

我写了一个解密类读取properties里面的数据库帐号和密码然后解密,为什么在需要操作数据库的时候,拿的还是我加密的密文,而没经过解密的方法了?有什么办法可以让spring去拿的是解密后的帐号密码,而不是密文

作者: scjingying   发布时间: 2011-11-24

楼主请尝试下继承PropertyPlaceholderConfigurer
然后覆写以下方法,应该可以解决你的问题
protected String convertPropertyValue(String originalValue) 
{
return originalValue;
}
Convert the given property value from the properties source to the value that should be applied.
The default implementation simply returns the original value. Can be overridden in subclasses, for example to detect encrypted values and decrypt them accordingly.

作者: zyz1985   发布时间: 2011-11-24

引用 1 楼 zyz1985 的回复:

楼主请尝试下继承PropertyPlaceholderConfigurer
然后覆写以下方法,应该可以解决你的问题
protected String convertPropertyValue(String originalValue)
{
return originalValue;
}
Convert the given property value from the proper……


貌似没用用,你可以详细点么?

作者: scjingying   发布时间: 2011-11-24