java代码读取properties配置文件实例
生活随笔
收集整理的這篇文章主要介紹了
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);}?
轉載于:https://www.cnblogs.com/ITzhangda/p/10954143.html
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的java代码读取properties配置文件实例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: sharepoint timer job
- 下一篇: 两种实现简单cp的方法