db.properties为src下的数据库配置文件,路径为config/props/db.properties
//读取数据库配置文件
public List<String> readDbProps(){
List<String> propList = new ArrayList<String>();
ClassLoader classLoader = DBConnection.class.getClassLoader();
Properties props = new Properties();
InputStream is =classLoader.getResourceAsStream("config" + File.separator + "props" + File.separator + "db.properties");
try {
props.load(is);
propList.add(props.getProperty("user"));
propList.add(props.getProperty("password"));
propList.add(props.getProperty("database"));
propList.add(props.getProperty("dbBackupSystem"));
}catch (Exception e) {
propList = null;
logger.error(e.getMessage(),e);
}
return propList;
}
url=jdbc:mysql://127.0.0.1:3306/dimdb
user=root
password=123
database=dimdb