First, the first download Redis, after decompression can be used without installation.
Redis server running redis-server.exe and Redis client redis-cli.exe
Second, open the Java development tools, import jar package commons-pool2-2.8.0.jar jedis-3.1.0.jar
Third, the input connection code Jedis
public void test(){
//获取连接
Jedis jedis = new Jedis("localhost",6379);
//操作
jedis.set("username","zhangsan");
//关闭连接
jedis.close();
}
operation result
Note: When you run Jedis connection code, the first server redis-server.exe open, otherwise it will not connect
Jar package and related tools download link: https: //blog.csdn.net/liangjiabao5555/article/details/104008439