Java the Redis Client Jedis
first, with Windows the eclipse in Redis that connects virtual machines the precautions
Disable Linux firewall: Execute command service iptables stop in Linux
Mine is already disabled,
Modify redis.conf to comment out bind 127.0.0.1, and then Protect-mode No
Second, the new Dynamic Java project,
① Guide Bag
Spit Groove, this workspace is Maven engineering, to other projects to copy a JUnit jar package can not find, very hard to find the package after the import run and error,
Java.lang.noclassdeffounderror:org/hamcrest/selfdescribing
At Java.lang.ClassLoader.defineClass1 (Native Method)
caused by:java.lang.ClassNotFoundException:org.hamcrest.SelfDescribing
② Test Connection
Third, test key
Jedis Jedis =NewJedis ("192.168.10.102", 6379); Set<String> KeySet = Jedis.keys ("*"); for(String key:keyset) {System.out.println (key); } System.out.println ("~~~~~~~~~~~~~~~~~~``````"); Iterator<String> iterator =Keyset.iterator (); while(Iterator.hasnext ()) {String key=Iterator.next (); SYSTEM.OUT.PRINTLN (key); } System.out.println ("~~~~~~~~~~~~~~~```````"); Boolean exists= Jedis.exists ("index"); SYSTEM.OUT.PRINTLN (exists);
Redis client Jedis for Java