properites配置文件与它的工具类
发布日期:2021-10-12 20:07:52 浏览次数:12 分类:技术文章

本文共 1643 字,大约阅读时间需要 5 分钟。

 配置文件

weixinpay.properties  配置文件##weixin_pay_APPIDWeiXin_AppId = wxfce80d1dsf934765793##åweixin_pay_mch_idWeiXin_MCH_ID=15035236491##weixin_pay_NOTIFY_URLWeiXin_NOTIFY_URL=m.wdefs.com/product/app/weiXinPayNotify##weixin_pay_Refund_UrlWeiXin_Refund_Url=C:/apiclient_cert/apiclient_cert.p12##WeiXin_Secret_Key= ##weixin_pay_Sign_KeyWeiXin_Sign_Key=VrYzT4sdDoCSGSCpKYWMZ3ZQy11fk2V

工具类  PropertiesUtil

/**	 * 	 * 

* Title: getProperty *

*

* Description: *

* * @param resourcePath * properties 路径 文件名 * @param key * 值对应的键 * @return */ public static String getProperty(String resourcePath, String key) { String value = ""; InputStream in = null; try { in = PropertiesUtil.class.getClassLoader().getResourceAsStream(resourcePath + ".properties"); Properties properties = new Properties(); InputStreamReader inputStreamReader = new InputStreamReader(in, "UTF-8"); properties.load(inputStreamReader); value = (String) properties.get(key); } catch (Exception e) { e.printStackTrace(); } finally { try { in.close(); } catch (Exception e2) { e2.printStackTrace(); } } return value; }

工具类调用配置文件读取所对应的值  WeiXinPayController

String WeiXin_AppId = PropertiesUtil.getProperty("weixinpay", "WeiXin_AppId"); //安卓     String WeiXin_MCH_ID = PropertiesUtil.getProperty("weixinpay", "WeiXin_MCH_ID");  //安卓     String WeiXin_NOTIFY_URL = PropertiesUtil.getProperty("weixinpay", "WeiXin_NOTIFY_URL");  //安卓     String WeiXin_Refund_Url = PropertiesUtil.getProperty("weixinpay", "WeiXin_Refund_Url");  //安卓     String WeiXin_Sign_Key = PropertiesUtil.getProperty("weixinpay", "WeiXin_Sign_Key");  //安卓

 

转载地址:https://blog.csdn.net/qq_39772439/article/details/88990512 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:button按钮颜色切换
下一篇:Linux下ngix开机自启

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年04月25日 05时30分27秒