redis_基础_基本使用

1、首先使用IDEA创建一个普通的WEB项目

  

2、下载Jar包

  需要common-pool和Jedis两个jar

  在阿里Maven仓库中能找到

  

    

3、将Jar包导入项目

  

4、编写Test类

  

import org.junit.Test;
import redis.clients.jedis.Jedis;

public class RedisTest {


    @Test
    public void test() {
        // 获得连接对象
        Jedis jedis = new Jedis("192.168.80.128", 6379);
        // 获取值
        System.out.println(jedis.get("username"));
        // 设置值
        jedis.set("address","江西");
        System.out.println(jedis.get("address"));
    }
}

猜你喜欢

转载自www.cnblogs.com/l48x4264l46/p/11055695.html