zoukankan      html  css  js  c++  java
  • 简单的读取配置文件的工具类

    import java.util.HashMap;

    import java.util.Map;

    import java.util.Properties;

    import org.springframework.beans.BeansException;

    import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

    import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

     

    public class PropertiesUtil

      extends PropertyPlaceholderConfigurer

    {

      private static Map<String, Object> ctxPropertiesMap = new HashMap();

      

      protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)

        throws BeansException

      {

        super.processProperties(beanFactoryToProcess, props);

        for (Object key : props.keySet())

        {

          String keyStr = key.toString();

          String value = props.getProperty(keyStr);

          ctxPropertiesMap.put(keyStr, value);

        }

      }

      

      public static Object getContextProperty(String name)

      {

        return ctxPropertiesMap.get(name);

      }

      

      public static String getContexrtParam(String name)

      {

        return (String)ctxPropertiesMap.get(name);

      }

      

      public static void load(Map map)

      {

        if ((map != null) && (!map.isEmpty())) {

          for (Object key : map.keySet()) {

            ctxPropertiesMap.put(key.toString(), map.get(key));

          }

        }

      }

    }

  • 相关阅读:
    spring 事务
    Servlet详解之两个init方法的作用
    被request.getLocalAddr()苦闷了很久
    Java获取IP地址:request.getRemoteAddr()警惕
    MongoDB笔记
    hexo+github搭建博客
    Python处理Excel(使用openpyxl库)
    Wireshark使用学习
    查看开启操作系统端口
    记录Centos7服务器搭建过程
  • 原文地址:https://www.cnblogs.com/tom-plus/p/7581439.html
Copyright © 2011-2022 走看看