https://github.com/xetorthio/jedis 讲解了如何在spring boot中加入jedis依赖,
在pom.xml下加入如下代码
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.8.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
在main函数中加入
Jedis jedis = new Jedis("localhost");
Scanner in=new Scanner(System.in);
while(true){
String name = in.next();
String value = jedis.get(name);
System.out.println(value);
}
首先安装完redis服务器,并运行redis服务(安装方法:http://blog.csdn.net/firenet1/article/details/50786562)
然后启用客户端输入一组数据
127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> get foo
"bar"
127.0.0.1:6379>
然后编译完后,在console里输入foo 会获得输出bar,此时已经测试工程可以正常联通redis
foo
bar
nulx
null
spring boot官网使用redis 的教程地址为http://spring.io/guides/gs/messaging-redis/