jedis连接redis单机

时间:2021-01-16 17:24:58

jedis连接redis单机

1.向pom文件添加jedis依赖:

                                     <dependency>
                                        <groupId>redis.clients</groupId>
                                        <artifactId>jedis</artifactId>
                                        <version>2.7.0</version>
                          </dependency>

2.实例链接:

                                     

                     //实例连接redis

                   @Test

                  public void testJedisSingle() {

 

                             Jedis jedis =new Jedis("192.168.101.3", 6379);

                             jedis.set("name","bar");

                            String name = jedis.get("name");

                            System.out.println(name);

                             jedis.close();

 

                 }