前提:Linux一定保持联网状态
首先将linux中的redis配置文件redis.conf
更改三个地方
注释掉bind
在第70行左右 (命令模式直接输入70G
就直接跳转)
更改protected-mode为no
在第88行
添加登录密码
在第789行的位置(更改为自己的密码我这里是123456)
这三个修改完成后Esc
然后:wq
保存退出
登录redis
正常登录只不过需要输入密码auth 密码
需要关闭防火墙
在一个新的终端输入
#关闭防火墙;systemctl stop firewalld.service#禁止防火墙启动;systemctl disable firewalld.service1234
idea创建一个springboot的项目(这个我就不说了)
在配置文件application.properties
中添加配置
Linux的ip地址,端口号和密码
------------(Linux中ip地址,在Linux中输入ifconfig
inet后面的就是)---------------
然后在测试类中测试即可
@SpringBootTestclass RedisSpringbootApplicationTests { @Autowired private RedisTemplate redisTemplate; @Test void contextLoads() { redisTemplate.opsForValue().set("mykey","hello yuaiiao"); System.out.println(redisTemplate.opsForValue().get("mykey")); }}123456789101112
显示成功
苏公网安备 32132202001088号
| Copyright 北极熊 北格技术 版权所有