poolman读取文件不支持加密解密的机制的话只能自己修改源码来实现了吧?
------------------------------------------------------------------------
通过万能的stackoverflow查找到了可行的解决思路:
1.编写自己的DataSourceFactory类,比如:package com.zuidaima.test;
import java.util.Properties;
import org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory;
public class CustomDataSourceFactory extends UnpooledDataSourceFactory {
@Override
public void setProperties(Properties properties) {
String user = null;
String pass = null;
// decrypt the file, use some fancy obfuscation, connect somewhere to get
// the username and password dynamically at startup, whatever...
//
// user = "JohnDoe";
// pass = "[email protected]$$word";
properties.put("username", user);
properties.put("password", pass);
super.setProperties(properties);
}
}
参考stackoverflow:http://stackoverflow.com/questions/8516989/encrypt-a-properties-file-for-ibatis
2.通过java开源技术框架Jasypt实现datasource.driver=com.mysql.jdbc.Driver
datasource.url=jdbc:mysql://zuidaima.com:3306/zuidaima_com
datasource.username=zuidaima.com
datasource.password=ENC(G6N718UuyPE5bHyWKyuLQSm02auQPUtm)
参考stackoverflow:http://stackoverflow.com/questions/23375989/encrypting-properties-file-and-persistence-xml
参考:http://stackoverflow.com/questions/11645477/how-to-store-password-as-encrypted-in-properties-file-in-spring