Redis Java客户端Jedis入门
Linux下redis的安装及运行可以参考随笔(redis入门与安装)一、jedis下载
在https://github.com/xetorthio/jedis/downloads上下载jedis-2.0.0.jar
二、将jedis-2.0.0.jar放入eclipse\plugins的目录中
打开Window->Preferences->Java->Install JREs
在jre6->Edit->Add External JARs把eclipse\plugins\jedis-2.0.0.jar添加进来。
三、进入Maven生成Helloworld编辑pom.xml
4.0.0
org.marshal
helloworld
1.0-SNAPSHOT
jar
helloworld
http://maven.apache.org
UTF-8
junit
junit
3.8.1
test
redis.clients
jedis
2.0.0
compile
四、编辑App.java
package org.marshal;
import redis.clients.jedis.Jedis;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
Jedis jedis = new Jedis("redis-server.ipaddress");//redis服务器地址
jedis.auth("requiepass");//验证密码
jedis.set("java", "java hello world");
String value = jedis.get("java");
System.out.println( value );
}
}
五、运行App程序
Hello World!
java hello world
六、Eclipse上jedis javadoc的关联
1、jedis-Javadoc的下载地址:
http://www.jarvana.com/jarvana/view/redis/clients/jedis
2、eclipse中javadoc的关联
页:
[1]