一、maven項目中直接引入Jedis包,非maven項目能夠下載相關的jar包java
<dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.6.1</version> </dependency>
二、鏈接redisredis
//鏈接本地redis服務,默認端口號6379 Jedis jedis = new Jedis("localhost"); //鏈接redis服務 //Jedis jedis = new Jedis("服務地址","端口號"); System.out.println("Connection to server sucessfully"); //查看服務是否運行 System.out.println("Server is running: " + jedis.ping());