创建maven项目
2.导入jar包
<dependencies> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.9.0</version> </dependency> </dependencies>
3.测试
package cn.zys.redis; import redis.clients.jedis.Jedis; public class redisTest { private static final String host = "192.168.6.178"; private static final int prot = 6379; public static void main(String[] args) { Jedis jedis = new Jedis(host,prot); System.out.println(jedis); String pong = jedis.ping(); System.out.println(pong + "测试是否连通"); } }