一、环境搭建
这里我使用的SpringBoot版本是2.6.3,所以我引入的Jedis相关版本也不是很高
<dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>3.2.0</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency>
二、测试代码
@Test
public void string(){
//Jedis连接 IP地址 端口号
Jedis jedis=new Jedis("192.168.66.147",6379);
jedis.set("u1","test1");
String u1 = jedis.get("u1");
}