博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SpringBoot整合redis-idea连接虚拟机中redis
阅读量:3951 次
发布时间:2019-05-24

本文共 788 字,大约阅读时间需要 2 分钟。

前提:Linux一定保持联网状态

  1. 首先将linux中的redis配置文件redis.conf更改三个地方
  • 注释掉bind

    在第70行左右 (命令模式直接输入70G就直接跳转)
    在这里插入图片描述

  • 更改protected-mode为no

    在第88行
    在这里插入图片描述

  • 添加登录密码

    在第789行的位置(更改为自己的密码我这里是123456)在这里插入图片描述
    这三个修改完成后Esc然后:wq保存退出

  1. 登录redis
    正常登录只不过需要输入密码auth 密码

在这里插入图片描述

  1. 需要关闭防火墙
    在一个新的终端输入
#关闭防火墙;systemctl stop firewalld.service#禁止防火墙启动;systemctl disable firewalld.service
  1. idea创建一个springboot的项目(这个我就不说了)
  2. 在配置文件application.properties中添加配置
    Linux的ip地址,端口号和密码
    在这里插入图片描述
    ------------(Linux中ip地址,在Linux中输入ifconfiginet后面的就是)---------------
    在这里插入图片描述
  3. 然后在测试类中测试即可
    在这里插入图片描述
@SpringBootTestclass RedisSpringbootApplicationTests {
@Autowired private RedisTemplate redisTemplate; @Test void contextLoads() {
redisTemplate.opsForValue().set("mykey","hello yuaiiao"); System.out.println(redisTemplate.opsForValue().get("mykey")); }}
  1. 显示成功
    在这里插入图片描述

看到最后的帮忙点个👍🙏 谢谢,这个对我真的很重要!
在这里插入图片描述

转载地址:http://mmqwi.baihongyu.com/

你可能感兴趣的文章
Providing Ancestral and Temporal Navigation 设计高效的应用导航
查看>>
Putting it All Together: Wireframing the Example App 把APP例子用线框图圈起来
查看>>
Implementing Lateral Navigation 实现横向导航
查看>>
Implementing Ancestral Navigation 实现原始导航
查看>>
Implementing Temporal Navigation 实现时间导航
查看>>
Responding to Touch Events 响应触摸事件
查看>>
Defining and Launching the Query 定义和启动查询
查看>>
Handling the Results 处理结果
查看>>
如何内置iperf到手机中
查看>>
如何adb shell进入ctia模式
查看>>
Contacts Provider 联系人存储
查看>>
android 图库播放幻灯片时灭屏再亮屏显示keyguard
查看>>
android 图库语言更新
查看>>
android camera拍照/录像后查看图片/视频并删除所有内容后自动回到camera预览界面
查看>>
android 图库中对非mp4格式的视频去掉"修剪"功能选项
查看>>
how to disable watchdog
查看>>
android SDIO error导致wifi无法打开或者连接热点异常的问题
查看>>
android USB如何修改Serial Number or SN?
查看>>
android 用svn管理的版本编译出来有问题
查看>>
android 如何用jar包代替java代码编译
查看>>