import com.lavasoft.freamwork.common.ThreeDES;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import java.util.Properties;
/**
* 重写PropertyPlaceholderConfigurer的processProperties方法实现
*
* @author leizhimin 2012-03-14 16:47
*/
public class PropertyPlaceholderConfigurerExt extends PropertyPlaceholderConfigurer{
@Override
protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props)
throws BeansException {
String password = props.getProperty( "jdbc.password");
if (password != null) {
//解密jdbc.password属性值,并重新设置
props.setProperty( "jdbc.password", ThreeDES.getDesString(password));
}
super.processProperties(beanFactory, props);
}
}
<!-- <context:property-placeholder location="classpath:jdbc.properties,classpath:tdmc.properties"/>-->
<!-- 加密时候使用 -->
<bean id="propertyConfig" class="com.lavasoft.freamwork.ext.spring.PropertyPlaceholderConfigurerExt">
<property name="locations">
<list>
<value>classpath:jdbc.properties </value>
<value>classpath:tdmc.properties </value>
</list>
</property>
</bean>
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://10.87.30.32:3306/tdmc_leizm
jdbc.user=root
#jdbc.password=123456
jdbc.password=tAeE2ib1ILE=
4.好多人都说路径找不到。其实要是放在web-inf下面直接写路径读取就行
直接上xml文件
这样就可以读取了。读取哪个配置哪个。