開啟IDEA並建立Maven專案
右鍵Project folder/Open Module Settings
Modules/Dependencies/+/Library/From Maven..
輸入jedis等幾秒後會出現搜尋到的套件,按下ok即可
第二種則是直接在pom.xml加入
<dependencies>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
</dependencies>
程式碼如下:
import redis.clients.jedis.Jedis;
public class test {
public static void main(String []args){
Jedis jedis = new Jedis("192.168.239.128");
jedis.set("test", "cy");
System.out.println(jedis.get("test"));
}
}
執行結果: