package com.bootdo.common.utils;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.util.HashMap;
import java.util.Properties;

/**
 * @author 宋显哲
 * @version 1.0.0 创建于 2017/12/28
 **/
public final class CommonConfUtil {
    private static final Logger logger = LogManager.getLogger(CommonConfUtil.class);
    private static HashMap<String, String> map = new HashMap<>();

    static {
        try {
            Properties properties = new Properties();
            properties.load(CommonConfUtil.class.getResourceAsStream("/common.properties"));
            properties.keySet().iterator().forEachRemaining(k -> map.put(String.valueOf(k), String.valueOf(properties.get(k))));
        } catch (IOException e) {
            logger.error("读取配置文件错误，错误信息：" + e.getMessage());
        }
    }

    public static String getConf(String key) {
        return map.get(key);
    }
}
