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));

          }

        }

      }

    }

  • 相关阅读:
    RabbitMQ消息队列
    集群概念
    重新学习CSS,认识CSS3中的属性
    计算机网络中,路由器和交换机的区别
    微信小程序中,如何点击链接跳转到外部网页
    微信小程序中,如何实现显示,隐藏密码的功能
    Vue 中引入echarts
    解决Ubuntu(linux)系统中PHP的curl函数无法使用的问题
    数据通信的基本知识
    计算机网络的性能
  • 原文地址:https://www.cnblogs.com/tom-plus/p/7581439.html
Copyright © 2011-2022 走看看