Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java HGETALL如何使用redisson_Java_Redis_Redisson - Fatal编程技术网

Java HGETALL如何使用redisson

Java HGETALL如何使用redisson,java,redis,redisson,Java,Redis,Redisson,我很难弄清楚如何使用redisson redis库访问地图键。我希望能够(使用redisson)访问由不使用redisson的系统创建的密钥。假设我使用redis cli sasus:16379> hset user fname "Nancy" (integer) 1 sasus:16379> hset user lname "Schmancy" (integer) 1 sasus:16379> hset user email "nanc@example.org" (integ

我很难弄清楚如何使用redisson redis库访问地图键。我希望能够(使用redisson)访问由不使用redisson的系统创建的密钥。假设我使用
redis cli

sasus:16379> hset user fname "Nancy"
(integer) 1
sasus:16379> hset user lname "Schmancy"
(integer) 1
sasus:16379> hset user email "nanc@example.org"
(integer) 1
sasus:16379> hset user system "none"
(integer) 1
sasus:16379> hgetall user
1) "fname"
2) "Nancy"
3) "lname"
4) "Schmancy"
5) "email"
6) "nanc@example.org"
7) "system"
8) "none"
Unrecognized token 'fname': was expecting 'null', 'true', 'false' or Nan
现在有一个简单的java方法来检索

public static void getNancy() {
    Config config = new Config();
    config.useSingleServer().setAddress("redis://sasus:16379");
    RedissonClient redisson = Redisson.create(config);
    RMap user = redisson.getMap("user");
    System.out.println("user: " + user);
    redisson.shutdown();
}
这将抛出一个
JacksonParseException

sasus:16379> hset user fname "Nancy"
(integer) 1
sasus:16379> hset user lname "Schmancy"
(integer) 1
sasus:16379> hset user email "nanc@example.org"
(integer) 1
sasus:16379> hset user system "none"
(integer) 1
sasus:16379> hgetall user
1) "fname"
2) "Nancy"
3) "lname"
4) "Schmancy"
5) "email"
6) "nanc@example.org"
7) "system"
8) "none"
Unrecognized token 'fname': was expecting 'null', 'true', 'false' or Nan
…在调用
getMap(“用户”)


我看到一些关于编解码器的讨论,但我不清楚这是否是解决方案。有人能给我指出正确的方向吗?这似乎是一个常见的用例。

例外情况是,Redisson检索到的数据不是有效的JSON格式字符串。您可以更改数据格式,也可以使用StringCodec而不是基于JSON的编解码器。

例外情况是,Redisson检索到的数据不是有效的JSON格式字符串。您可以更改数据格式,也可以使用StringCodec而不是基于JSON的编解码器。

Ugh!我的问题被弄糟了。有人能把它编辑成“我如何使用redisson做HGETALL?”啊!我的问题被弄糟了。是否有人可以将其编辑为“如何使用redisson实现HGETALL?”它不能是
StringCodec
。它只返回
Map
对象(例如
org.redisson)的
toString()
值。RedissonMap@67fe2a5a
)。我是否应该使用另一个编解码器?恐怕这正是您编写代码的目的:打印
Map
对象的参考值。如果要显示地图的内容,请尝试遍历地图,然后打印键/值,或使用readAll方法之一。它不能是
StringCodec
。它只返回
Map
对象(例如
org.redisson)的
toString()
值。RedissonMap@67fe2a5a
)。我是否应该使用另一个编解码器?恐怕这正是您编写代码的目的:打印
Map
对象的参考值。如果要显示映射的内容,请尝试对其进行迭代,然后打印键/值,或者使用readAll方法之一。