先列出配置
app.properties
oracle.jdbc.driverClassName=XXXXX
oracle.jdbc.url=XXXXX
oracle.jdbc.username=abc
oracle.jdbc.password=MTIz
#password經BASE64加密 123->MTIz
application.xml
<bean id="configBean"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>file:///C:/app.properties</value>
<value>classpath*:*.properties</value>
</list>
</property>
</bean>
<bean id="oracleReadWriteDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${oracle.jdbc.driverClassName}"/>
<property name="url" value="${oracle.jdbc.url}"/>
<property name="username" value="${oracle.jdbc.username}"/>
<property name="password" value="${oracle.jdbc.password}"/>
<property name="minIdle" value="1" /><!-- connection pool最小idle的連線數 -->
<property name="maxActive" value="50"/>
<property name="initialSize" value="1" />
<property name="timeBetweenEvictionRunsMillis" value="600000" />
<property name="minEvictableIdleTimeMillis" value="1800000" />
<property name="validationQuery" value="select 1 from dual" />
<property name="testWhileIdle" value="true" />
<property name="testOnBorrow" value="true" />
<property name="testOnReturn" value="false" />
<property name="connectionInitSqls" value="select 2 from dual" />
<property name="defaultAutoCommit" value="false"/>
</bean>
我的問題是...
<property name="password" value="${oracle.jdbc.password}"/>
上圖的value,
我想得到經BASE64 DECODE的密碼也就是MTIz->123
如下圖
<property name="password" value="123"/>
有辦法做到嗎?
吐槽:問個問題都寫不好是什麼概念...
沒仔細看還以為你在分享程式勒
另外繼承BasicDataSource實作就好
太細節就不寫了,好懶r
public class BasicDataSource extends BasicDataSource {
@Override
public String setPassword(final String password) {
this.password = decode(password);
}
private String decode(String password) {
// decode 1.
// decode 2..
// decode 3...
// done!
return decode_password;
}
}
xml改這邊
<bean id="oracleReadWriteDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
改成
<bean id="oracleReadWriteDataSource" class="your.package.path.CustomDataSource" destroy-method="close">