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



}

猜你喜欢

转载自blog.csdn.net/dayuweixia/article/details/43796479
今日推荐