zoukankan      html  css  js  c++  java
  • 1.系统代码读取配置文件

    // 配置文件名
    private static final String CONFIG_CONTEXT_FILE_NAME = "context-zzgjs.properties";

    private static Configuration ins=null;

    private static Log log=LogFactory.getLog(Configuration.class);

    static {
    Properties datas = new Properties();
    try {
    datas.load(Configuration.class.getClassLoader().getResourceAsStream(CONFIG_CONTEXT_FILE_NAME));
    } catch (IOException e) {
    throw new PafaRuntimeException("Could not load configure file in classpath: "
    + CONFIG_CONTEXT_FILE_NAME + "!", e);
    }
    ins=new Configuration(datas);

    }

    private Configuration(Properties configure){
    super(configure);
    }

    /**
    * 得到配置属性值
    *
    * @param key 属性名称
    * @return 属性值
    */
    public static String getValue(String key) {
    String value=ins.getString(key);
    if(value==null){
    log.warn("Cofig item ["+key+"] is null");
    }
    return value;
    }

    /**
    * 得到配置属性值
    *
    * @param key 属性名称
    * @param defaultValue 默认值
    * @return 属性值
    */
    public static String getValue(String key, String defaultValue) {
    return ins.getString(key,defaultValue);
    }

    public static Map getConfig(){
    return ins.datas;
    }

    public static Configuration getInstance(){
    return ins;
    }
    }

  • 相关阅读:
    项目功能规格说明书
    团队工作准则&贡献分配规则
    Scrum Meeting Alpha
    用户需求与NABCD分析
    团队项目选题-博客园移动客户端
    团队作业Week3
    爱情小故事
    高手遇事的处理方法,学会你也是高手
    富人思维--目标导向
    有一种失败叫瞎忙
  • 原文地址:https://www.cnblogs.com/panxuejun/p/6245587.html
Copyright © 2011-2022 走看看