1. 程式人生 > >ssh中資料庫配置檔案加密方法

ssh中資料庫配置檔案加密方法

 在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);
}



}