ssh中数据库配置文件加密方法

来源:互联网 发布:一淘和淘宝哪个比较好 编辑:程序博客网 时间:2024/05/17 08:36

 在applicationContext.xml文件中

<bean id="propertyConfigurer" class="com.common.util.ProPertyPlaceholderConfigure"> 

                <property name="locations"> 
                    <list>
                       <value>classpath:application.properties</value> 
                    </list>
                </property>
                <property name="fileEncoding" value="utf-8"/> 

        </bean>


package com.common.util;


import java.util.Properties;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

public class ProPertyPlaceholderConfigure  extends PropertyPlaceholderConfigurer{
protected void processProperties(ConfigurableListableBeanFactory beanFactory,Properties props)
throws BeansException{

props.setProperty("jdbc.password", RSAUtils.decritp(props.getProperty("jdbc.password")));
super.processProperties(beanFactory, props);
}



}

0 0
原创粉丝点击