博客
关于我
springboot redis key乱码
阅读量:653 次
发布时间:2019-03-16

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

原写法:

@Autowiredprivate RedisTemplate redisTemplate;

 

写入redis后,查看key值

127.0.0.1:6379> keys *1) "\xac\xed\x00\x05t\x00#ContentPlatform2:ES:UpSertESContent"2) "\xac\xed\x00\x05t\x00%ContentPlatform2:Lock_v16:CJH_ARTICLE"3) "\xac\xed\x00\x05t\x00!ContentPlatform2:Lock_v16:V_VIDEO"4) "\xac\xed\x00\x05t\x00\x1bContentPlatform2:ES:Content"5) "\xac\xed\x00\x05t\x00#ContentPlatform2:Lock_v16:CJH_VIDEO"6) "\xac\xed\x00\x05t\x00%ContentPlatform2:Lock_v16:CMS_ARTICLE"

 

解决方式:

private RedisTemplate redisTemplate;@Autowired(required = false)public void setRedisTemplate(RedisTemplate redisTemplate) {     RedisSerializer stringSerializer = new StringRedisSerializer();     redisTemplate.setKeySerializer(stringSerializer);     redisTemplate.setValueSerializer(stringSerializer);     redisTemplate.setHashKeySerializer(stringSerializer);     redisTemplate.setHashValueSerializer(stringSerializer);     this.redisTemplate = redisTemplate;}

 

调整后查看redis key值:

127.0.0.1:6379> keys *1) "ContentPlatform2:Lock_v17:V_VIDEO"2) "ContentPlatform2:Lock_v17:CMS_ARTICLE"3) "ContentPlatform2:ES:Content"4) "ContentPlatform2:Lock_v17:CJH_ARTICLE”

 

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

你可能感兴趣的文章
使用 TortoiseGit 时,报 Access denied 错误
查看>>
基于 HTML5 WebGL 的污水处理厂泵站自控系统
查看>>
django-表单之模型表单渲染(六)
查看>>
c++之程序流程控制
查看>>
spring-boot-2.0.3之redis缓存实现,不是你想的那样哦!
查看>>
有道云笔记 同步到我的博客园
查看>>
李笑来必读书籍整理
查看>>
Hadoop(十六)之使用Combiner优化MapReduce
查看>>
《机器学习Python实现_10_06_集成学习_boosting_gbdt分类实现》
查看>>
CoreCLR源码探索(八) JIT的工作原理(详解篇)
查看>>
andriod 开发错误记录
查看>>
C语言编译错误列表
查看>>
看明白这两种情况,才敢说自己懂跨链! | 喵懂区块链24期
查看>>
CentOS5 Linux编译PHP 报 mysql configure failed 错误解决办法
查看>>
pycharm新建文件夹时新建python package和新建directory有什么区别?
查看>>
python中列表 元组 字典 集合的区别
查看>>
Android DEX加固方案与原理
查看>>
iOS_Runtime3_动态添加方法
查看>>
Leetcode第557题---翻转字符串中的单词
查看>>
Problem G. The Stones Game【取石子博弈 & 思维】
查看>>