使用ResourceBundle替代properties类读取配置文件

欢迎大家加入我的github项目,一起学习,一起发展
---> 全栈工程师进阶学习站
---> 我的前端学习笔记
--->行业内最新最群的报告,工作日每日更新

—>原生 js 训练计划

 Properties props = new Properties();
        //  props.load(JedisPoolUtil.class.getClassLoader().getResourceAsStream("jedis.properties"));

        ResourceBundle bundle = ResourceBundle.getBundle("jedis");

        //获取数据,加载到jedisPoolConfig下
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        //   jedisPoolConfig.setMaxTotal(Integer.parseInt(props.getProperty("maxTotal")));
        jedisPoolConfig.setMaxTotal(Integer.parseInt(bundle.getString("maxTotal")));
        // jedisPoolConfig.setMaxIdle(Integer.parseInt(props.getProperty("maxIdle")));
        jedisPoolConfig.setMaxIdle(Integer.parseInt(bundle.getString("maxIdle")));

        //初始化 jedisPool
      //  jedisPool=  new JedisPool(jedisPoolConfig, props.getProperty("host"), Integer.parseInt(props.getProperty("port")));
        jedisPool=  new JedisPool(jedisPoolConfig, bundle.getString("host"), Integer.parseInt(bundle.getString("port")));

  
使用ResourceBundle替代properties类  
要注意的是资源路径前面不要加斜杠,并且不需要文件拓展名(前提是必须是properties)
如果是properties类的话,需要加斜杠


```闲聊时刻

10年短信公司,互联网100强企业!主营业务:短信(国内和国际)App H5一键免密登录,防薅羊毛接口,图片OCR,空号检测,活跃号检测,人证核验,活体检测,高防ddos攻击等等200多个企业服务接口!需要的联系他13592366783 官方链接:https://zz.253.com/v5.html#/register?uid=1953

自己公司需求 偶然间 用了一家第三方接口供应商,产品应有尽有,很齐全,对接文档非常详细,彼此都很节约时间,主要非常稳定,包括服务方面很给力,有兴趣的博友,可以联系他,算是对合作伙伴的支持了


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值