读取代码:

package com.jz.compute.mc.v2.config;

import java.util.Enumeration;
import java.util.ResourceBundle;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

public class PropertiesConfig {

    public static volatile ConcurrentMap<String, String> applicationMap = new ConcurrentHashMap<>();
    private final static String dev = "dev";
    private final static String test = "test";
    private final static String prod = "prod";

    private PropertiesConfig() {
    }

    public static ConcurrentMap<String, String> getInstance() {
        return getInstance("application-");

    }

    public static ConcurrentMap<String, String> getInstance(String filePrefix) {
        if (applicationMap.size() == 0) {
            synchronized (PropertiesConfig.class) {
                if (applicationMap.size() == 0) {
                    ResourceBundle application = ResourceBundle.getBundle("application");
                    ResourceBundle applicationActive = null;
                    String profilesActive = application.containsKey("profiles.active")
                            ? application.getString("profiles.active") : "";
                    if (PropertiesConfig.prod.equals(profilesActive)) {
                        applicationActive = ResourceBundle.getBundle(filePrefix + "prod");
                    } else if (PropertiesConfig.test.equals(profilesActive)) {
                        applicationActive = ResourceBundle.getBundle(filePrefix + "test");
                    } else if (PropertiesConfig.dev.equals(profilesActive)) {
                        applicationActive = ResourceBundle.getBundle(filePrefix + "dev");
                    } else {
                    }

                    Enumeration<String> keys = application.getKeys();
                    while (keys.hasMoreElements()) {
                        String key = keys.nextElement();
                        applicationMap.put(key, application.getString(key));
                    }
                    if (null != applicationActive) {
                        keys = applicationActive.getKeys();
                        while (keys.hasMoreElements()) {
                            String key = keys.nextElement();
                            applicationMap.put(key, applicationActive.getString(key));
                        }
                    }
                }
            }
        }
        return applicationMap;
    }

    public static void main(String[] args) {
        System.out.println(PropertiesConfig.getInstance().getOrDefault("eicost.url", ""));
    }

}

 

posted @ 2019-06-15 14:35 carlo-z 阅读(431) 评论(0) 推荐(0) 编辑
摘要: public static Map invokeCapp(String URL, Map paramMap) throws Exception { Map map = new HashMap(); RequestConfig requestConfig = RequestConfig.custom() .setConnectTimeout(200... 阅读全文
posted @ 2019-01-29 11:31 carlo-z 阅读(5163) 评论(0) 推荐(0) 编辑
摘要: public static Map invokeCapp(String urlStr, Map params) throws Exception { Map map = new HashMap(); // post参数 StringBuilder postData = new StringBuilder(); for (Map.Entry param : par... 阅读全文
posted @ 2019-01-29 11:30 carlo-z 阅读(10906) 评论(0) 推荐(0) 编辑
摘要: 使用方法 阅读全文
posted @ 2019-01-18 16:25 carlo-z 阅读(7750) 评论(0) 推荐(0) 编辑
摘要: 普通 curl post 请求 curl请求中设置 cookie 在返回值中设置cookie (在服务端 登录 后台,再设置好cookie,返回 前端) 方式1: 方式2: 阅读全文
posted @ 2018-07-09 10:16 carlo-z 阅读(3419) 评论(0) 推荐(0) 编辑
摘要: 结果 阅读全文
posted @ 2016-12-05 16:52 carlo-z 阅读(877) 评论(0) 推荐(0) 编辑
摘要: select table_schema, concat(truncate(sum(data_length)/1024/1024,2),' mb') as data_size,concat(truncate(sum(index_length)/1024/1024,2),'mb') as index_s 阅读全文
posted @ 2016-07-14 16:57 carlo-z 阅读(350) 评论(0) 推荐(0) 编辑
摘要: 指定Maven的版本,并且指定Maven使用的jdk版本在pom.xml中修改 ... org.apache.maven.plugins maven-compiler-plugin ... 阅读全文
posted @ 2015-12-01 14:24 carlo-z 阅读(58795) 评论(2) 推荐(5) 编辑
摘要: 1. php版本选择 1.1 PHP非线程安全与线程安全版本的选择技巧 1.2 版本区别PHP的大版本主要分三支:PHP4/PHP5/PHP6其中,PHP4由于太古老、对QQ支持不力已基本被淘汰,请无视PHP4。PHP6由于基本没有生产线上的应用,还基本只是一款概念产品,很多功能已在PHP5.3.... 阅读全文
posted @ 2015-11-30 18:12 carlo-z 阅读(262) 评论(0) 推荐(0) 编辑
摘要: 桌面看腻了?试试这 4 款漂亮的 Linux 图标主题吧http://linux.cn/article-4332-1.htmlFlatabuloushttps://github.com/anmoljagetia/Flatabulous 阅读全文
posted @ 2015-11-22 21:01 carlo-z 阅读(980) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示