zoukankan      html  css  js  c++  java
  • java代码读取properties配置文件实例

    简单的配置文件示例

    #接口认证key
    apiKey=4fGz356XAjWScx31tRBgePgY6Ma3eQM9i1vj
    
    #平台编码
    sourceCode=CERT2019041
    
    #test接口地址
    #用户
    ENDPOINT1=https://api.ifcert.org.cn/p2p/userInfo/test
    #散标
    ENDPOINT2=https://api.ifcert.org.cn/p2p/scatterInvest/test
    #散标状态
    ENDPOINT5=https://api.ifcert.org.cn/p2p/status/test
    #还款计划
    ENDPOINT10=https://api.ifcert.org.cn/p2p/repayPlan/test
    #债权信息
    ENDPOINT9=https://api.ifcert.org.cn/p2p/creditor/test
    #转让项目
    ENDPOINT6=https://api.ifcert.org.cn/p2p/transferProject/test
    #转让状态
    ENDPOINT12=https://api.ifcert.org.cn/p2p/transferStatus/test
    #承接信息
    ENDPOINT11=https://api.ifcert.org.cn/p2p/underTake/test
    #交易流水
    ENDPOINT4=https://api.ifcert.org.cn/p2p/transact/test
    #产品信息
    ENDPOINT13=https://api.ifcert.org.cn/p2p/lendProduct/test
    #产品配置
    ENDPOINT14=https://api.ifcert.org.cn/p2p/lendProductConfig/test
    #投资明细
    ENDPOINT15=https://api.ifcert.org.cn/p2p/lendParticulars/test

    代码示例

        @RequestMapping(value = "register", method = RequestMethod.GET)
        @AvoidDuplicateSubmission(needSaveToken = true)
        public ModelAndView register(String referrer) {
            Properties props = new Properties();
            try {
                props.load(Thread.currentThread().getContextClassLoader()
                        .getResourceAsStream("config/dataaccess/access.properties"));
            } catch (FileNotFoundException e) {
                throw new RuntimeException("找不到配置chinapnr.properties文件", e);
            } catch (IOException e) {
                throw new RuntimeException("读取配置chinapnr.properties文件出错", e);
            }
            String a = props.getProperty("apiKey");
            String b = props.getProperty("sourceCode");
            String c = props.getProperty("ENDPOINT1");
    
    
            System.out.println(a+";"+b+";"+c);
        }
  • 相关阅读:
    c# DES加密解密
    命令行远程调用图形界面程序
    mpv0.29 vo=x11 resize窗口渲染存在不正常黑色显示
    记qt 焦点状态在多个子窗口的关系
    linux_虚拟机终端连接方法
    python_爬虫_微信公众号抓取
    python_爬虫_multiprocessing.dummy以及multiprocessing
    python_爬虫_腾讯新闻app 单页新闻数据分析爬取
    python_爬虫_Charles手机证书安装问题
    python_爬虫_Selenium_Error
  • 原文地址:https://www.cnblogs.com/ITzhangda/p/10954143.html
Copyright © 2011-2022 走看看