读取resources下的配置文件

阅读 86

2022-03-14

Properties pro = PropertiesLoaderUtils.loadAllProperties("db.properties");
            Set<Map.Entry<Object, Object>> entries = pro.entrySet();
            for (Map.Entry<Object, Object> entry : entries) {
                String value =(String)entry.getValue();
                value = URLEncoder.encode(value, "UTF8");
                value = URLDecoder.decode(value, "GBK");
                if ("mysql.username".equals(entry.getKey())){
                    user= value;
                }
                if ("mysql.password".equals(entry.getKey())){
                    password= value;
                }
                if ("mysql.dbname".equals(entry.getKey())){
                    database= value;
                }
            }

精彩评论(0)

0 0 举报