java读取properties文件

来源:互联网 发布:mysql employees 导入 编辑:程序博客网 时间:2024/06/02 01:28
private static final String redisPropertiesFileName = "redis.properties";static {  inputStream = JedisPoolImpl.class.getResourceAsStream("/"+redisPropertiesFileName);  Properties pro = new Properties();    try {   pro.load(inputStream);      JedisPoolConfig config = new JedisPoolConfig();   config.setMaxTotal(Integer.parseInt(pro.getProperty("redis.pool.maxTotal")));//setMaxActive   config.setMaxIdle(Integer.parseInt(pro.getProperty("redis.pool.maxIdle")));   config.setMaxWaitMillis(Integer.parseInt(pro.getProperty("redis.pool.maxWaitMillis")));//setMaxWait   config.setTestOnBorrow(true);   String ip = pro.getProperty("redis.host");//读取配置文件   int port = Integer.parseInt(pro.getProperty("redis.port"));//读取配置文件   String password = pro.getProperty("redis.password");   int timeOut = Integer.parseInt(pro.getProperty("redis.timeout"));   if (StringUtils.isNotBlank(ip) && port > 1000) {    pool = new JedisPool(config, ip,      port, timeOut,password);    LOG.info("jedisPool ready on : host " + ip + " port "      + port + " ...");   } else {    LOG.error("jedisPool init false ...");   }  } catch (Exception e) {   LOG.error("jedisPool init false ...");  } }


0 0