0%
前言
SpringBoot项目整合Jedis
添加依赖
pom.xml
1 2 3 4
| <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> </dependency>
|
建立连接
1 2 3 4 5 6
| @Test public void test01() { Jedis jedis = new Jedis("127.0.0.1", 6379); jedis.set("key","value"); System.out.println(jedis.get("key")); }
|
如果有密码
<pwd>
:密码
1 2 3 4 5 6 7
| @Test public void test01() { Jedis jedis = new Jedis("127.0.0.1", 6379); jedis.auth("<pwd>") jedis.set("key","value"); System.out.println(jedis.get("key")); }
|
完成