Skip to content

Latest commit

 

History

History
40 lines (27 loc) · 782 Bytes

7.md

File metadata and controls

40 lines (27 loc) · 782 Bytes

Jedis

使用java操作redis的api,是redis官方推荐的java连接开发工具。使用java操作redis中间件。

使用步骤

  1. 新建maven项目,导入对应依赖

    <dependency>
        <groupId>redis.clients</groupId>
        <artifactId>jedis</artifactId>
        <version>3.6.0</version>
    </dependency>
    
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>fastjson</artifactId>
        <version>1.2.58</version>
    </dependency>
  2. 测试连接

    package com.sample;
    
    import redis.clients.jedis.Jedis;
    
    public class TestPing {
    
      public static void main(String[] args) {
        Jedis jedis = new Jedis("127.0.0.1", 6379);
        System.out.println(jedis.ping());
      }
    }