文章目录
- 1、Jedis简介
- 2、环境准备
- 3、创建maven普通项目,导入如下依赖
- 4、测试JAVA程序和Redis之间的通信
1、Jedis简介
"Jedis" 通常是作为 "Java Redis" 的缩写或简称来理解的。Java Embedded Data Structures Interface 表示 Java嵌入式数据结构接口
2、环境准备
3、创建maven普通项目,导入如下依赖
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.atguigu</groupId><artifactId>redis-jedis</artifactId><version>1.0-SNAPSHOT</version><dependencies><dependency><groupId>redis.clients</groupId><artifactId>jedis</artifactId><version>2.9.0</version></dependency><dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter-api</artifactId><version>5.8.1</version><scope>test</scope></dependency></dependencies></project>
4、测试JAVA程序和Redis之间的通信
package com.atguigu.jedis;
import org.junit.jupiter.api.Test;
import redis.clients.jedis.Jedis;
public class Test01 {@Testpublic void test01(){Jedis jedis = new Jedis("192.168.74.148", 6379);String pong = jedis.ping();System.out.println("pong = " + pong);jedis.close();}
}