MyPropertyPlaceholderConfigurer.java
963 Bytes
package cn.csbr.configenc;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.stereotype.Component;
@Component
public class MyPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {
protected String convertProperty(String propertyName, String propertyValue) {
//这里做对属性的内容的加解密等操作
//TODO something
if (propertyName.equalsIgnoreCase("spring.datasource.url")
|| propertyName.equalsIgnoreCase("spring.datasource.username") ||
propertyName.equalsIgnoreCase("spring.datasource.password")) {
// System.out.println;
// propertyValue = propertyValue.replace("abc", "");
// propertyValue=DesUtil.decrypt(propertyValue,DesUtil.KEY);
System.out.println(propertyName+":"+propertyValue);
}
return super.convertProperty(propertyName,propertyValue);
}
}