File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,16 @@ public static Properties loadProperties(String filename) {
2020 in = PropertiesUtil .class
2121 .getResourceAsStream (filename );
2222 properties .load (in );
23+ //如果配置文件存在jar包之外
24+ // String redisConf=System.getProperty("user.dir") + File.separator + "config" + File.separator+filename;
25+ // File file = new File(redisConf);
26+ // if (file.exists()) {
27+ // System.out.println("redis.properties配置文件存在,其路径为:" + file.getCanonicalPath());
28+ // in = new FileInputStream(file);
29+ // properties.load(in);
30+ // } else {
31+ // System.out.println("log4j2.xml配置文件不存在,log4j2初始化失败");
32+ // }
2333 } catch (IOException e ) {
2434 LOGINFO .error ("读取配置文件失败:" ,e );
2535 LOGERROR .error ("读取配置文件失败:" ,e );
Original file line number Diff line number Diff line change 77
88public class RedisPool {
99 private static JedisPool pool ;//jedis连接池
10- private static Properties properties = PropertiesUtil .loadProperties ("/ redis.properties" );
10+ private static Properties properties = PropertiesUtil .loadProperties ("redis.properties" );
1111 private static Integer maxTotal = Integer .parseInt (properties .getProperty ("redis.max.total" ,"20" )); //最大连接数
1212 private static Integer maxIdle = Integer .parseInt (properties .getProperty ("redis.max.idle" ,"20" ));//在jedispool中最大的idle状态(空闲的)的jedis实例的个数
1313 private static Integer minIdle = Integer .parseInt (properties .getProperty ("redis.min.idle" ,"20" ));//在jedispool中最小的idle状态(空闲的)的jedis实例的个数
@@ -39,7 +39,10 @@ private static void initPool(){
3939 }
4040
4141 public static Jedis getJedis (){
42- return pool .getResource ();
42+ Jedis jedis =pool .getResource ();
43+ //默认使用db0数据库,这里,我们手动选择db0数据库,方便后期更改
44+ jedis .select (0 );
45+ return jedis ;
4346 }
4447
4548
You can’t perform that action at this time.
0 commit comments