gpt4 book ai didi

java - Jedis 中的响应对象 - 抛出 ClassCastException

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:21:56 25 4
gpt4 key购买 nike

在 Jedis 中使用响应对象,抛出 ClassCastException 。当我使用管道时,我无法从 Redis 获得任何值(value)。请帮忙。我正在使用 Jedis 2.1.0

public class JedisPipeline {    
public static void main(String args[]){
final JedisPool pool = new JedisPool(new JedisPoolConfig(), "127.0.0.1", 6379);
Jedis jedis = pool.getResource();
Pipeline pipeline = jedis.pipelined();
pipeline.multi();
HashMap<String,String> map = new HashMap<String,String>();
map.put("50", "50");
pipeline.hmset("Id",map);
Response <Long> incr = pipeline.hincrBy("Id", "100", 100);
Response<Map<String,String>> map1 = pipeline.hgetAll("Id");
pipeline.exec();
List<Object> results = pipeline.syncAndReturnAll();
System.out.println(results);
System.out.println( incr.get());
System.out.println( map1.get());
pool.returnResource(jedis);
pool.destroy();
}
}

Exception in thread "main" java.lang.ClassCastException: [B cannot be cast to java.lang.Long
at redis.clients.jedis.BuilderFactory$4.build(BuilderFactory.java:45)
at redis.clients.jedis.BuilderFactory$4.build(BuilderFactory.java:48)
at redis.clients.jedis.Response.get(Response.java:27)
at redis.clients.jedis.Pipeline.syncAndReturnAll(Pipeline.java:42)
at com.work.jedis.JedisPipeline.main(JedisPipeline.java:28)

最佳答案

我使用的 jar 文件有冲突。我在构建路径中错误地保留了 jedis 2.1.0 和 jedis 2.0.0。

关于java - Jedis 中的响应对象 - 抛出 ClassCastException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16152748/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com