对于redis没有设置密码情况,直接去掉类中的密码即可
package com.practice.utils;
import redis.clients.jedis.jedis;
import redis.clients.jedis.jedispool;
import redis.clients.jedis.jedispoolconfig;
import java.util.resourcebundle;
/**
@since 1.0.0
*/
public class jedispoolutils {
/** 定义最大空闲数 */
private static int max_idle;
/** 定义最小空闲数 */
private static int min_idle;
/** 定义最大连接数 */
private static int max_total;
/** 定义远程ip地址 */
private static string url;
/** 定义连接端口号 */
private static int port;
/** 定义redis客户端登录密码 */
private static string password;
/** 定义连接超时时间 */
private static int time_out;
/** 创建jedispool对象,定义为空,等待初始化 */
private static jedispool pool = null;
@return
*/
private static jedispoolconfig init() {
//读取并加载初始化参数
resourcebundle bundle = resourcebundle.getbundle("redis");
max_idle = integer.valueof(bundle.getobject("redis.maxidle").tostring());
min_idle = integer.valueof(bundle.getobject("redis.minidle").tostring());
max_total = integer.valueof(bundle.getobject("redis.maxtotal").tostring());
url = bundle.getstring("redis.url");
port = integer.valueof(bundle.getobject("redis.port").tostring());
password = bundle.getstring("redis.password");
time_out = integer.valueof(bundle.getobject("redis.timeout").tostring());
//创建连接池配置对象
jedispoolconfig poolconfig = new jedispoolconfig();
poolconfig.setmaxidle(max_idle);
poolconfig.setminidle(min_idle);
poolconfig.setmaxtotal(max_total);
return poolconfig;
}
}
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
荐 Python部分第三方库简要介绍及近期Python入门学习笔记
荐 PCA降维原理及其代码实现(附加 sklearn PCA用法参数详解)
网友评论