Redis开启远程连接
1 开启远程连接
redis默认是不支持远程连接,需要手动开启,在redis.conf文件中,找到下方法代码:
#bind 127.0.0.1
这里只允许127.0.0.1登录,注释掉
开启密码校验,去掉requirepass的注析
requirepass password
//设置密码为password(自定义的,随便设)
改完之后,保存退出,启动redis
redis-server redis.conf
2 Jedis连接Redis
首先创建一个maven项目
Jedis的GitHub地址:https://github.com/xetorthio/jedis
项目创建成功后,添加Jedis依赖