jedis学习
初识Jedis
创建maven项目
导入依赖
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21<dependencies>
<!--jedis-->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>4.1.1</version>
</dependency>
<!--单元测试-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>5.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>测试
使用测试单元测试
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28public class JedisTest {
private Jedis jedis;
void setUp(){
jedis = JedisPoolTest.getJedis();
jedis.auth("000415");
jedis.select(0);
}
void testString(){
HashMap<String,String> map = new HashMap<>();
map.put("name","lihua");
map.put("age","13");
jedis.hmset("doc:1",map);
System.out.println(jedis.hgetAll("doc:1"));
}
void tearDown(){
if(jedis != null){
jedis.close();
}
}
}
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 好高骛远!