为了不会出现下面两个异常
- Exception in thread “main” redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketT 异常
- DENIED Redis is running in protected mode because protected mode is enabled 异常
首先在虚拟机端要对redis进行一些配置
打开redis.config文件
修改几处:
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1 不是注释这个
#bind 127.0.0.1 这里要注释掉
接下来要设置redis密码
config get requirepass #查看是否已经设置密码
config set requirepass "密码"
auth 密码 #访问
如何不设置密码,就修改redis.config中的配置(不推荐)