RedisTemplate 报错 Unexpected token (VALUE_NUMBER_INT), expected VALUE_STRING: need JSON String that contains type id (for subtype of java.lang.Object) at [Source: (byte[])"

报错内容

Unexpected token (VALUE_NUMBER_INT), expected VALUE_STRING: need JSON String that contains type id (for subtype of java.lang.Object)
at [Source: (byte[])"xxx"; line: 1, column: 2]

环境说明

使用 Redis Desktop Manager 写到 Redis 中的字符串, 使用程序读取报这个错的原因是: RedisTemplate 将操作的字符串识别成了 JSON 对象

解决方式

在使用 Redis Desktop Manager 将字符串 set 到 Redis 时使用单引号扩住双引号在扩住字符串
示例: set xxxKey '"[aaa,bbb]"'

posted @ 2022-04-02 14:50  kmswilliam  阅读(1707)  评论(0)    收藏  举报