解决测试redis集群时报"java.lang.NumberFormatException: For input string: "7003@17003..7002@17002"等异常
一、前言
关于redis5.0的集群模式下,通过客户端测试代码调试报"Exception in thread "main" java.lang.NumberFormatException: For input string: "7003@17003..7002@17002"等异常,详情日志如下>>
Exception in thread "main" java.lang.NumberFormatException: For input string: "7003@17003"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:)
at java.lang.Integer.parseInt(Integer.java:)
at java.lang.Integer.valueOf(Integer.java:)
at redis.clients.util.ClusterNodeInformationParser.getHostAndPortFromNodeLine(ClusterNodeInformationParser.java:)
at redis.clients.util.ClusterNodeInformationParser.parse(ClusterNodeInformationParser.java:)
at redis.clients.jedis.JedisClusterInfoCache.discoverClusterNodesAndSlots(JedisClusterInfoCache.java:)
at redis.clients.jedis.JedisClusterConnectionHandler.initializeSlotsCache(JedisClusterConnectionHandler.java:)
at redis.clients.jedis.JedisClusterConnectionHandler.<init>(JedisClusterConnectionHandler.java:)
at redis.clients.jedis.JedisSlotBasedConnectionHandler.<init>(JedisSlotBasedConnectionHandler.java:)
at redis.clients.jedis.JedisCluster.<init>(JedisCluster.java:)
at redis.clients.jedis.JedisCluster.<init>(JedisCluster.java:)
at redis.clients.jedis.JedisCluster.<init>(JedisCluster.java:)
at redis.clients.jedis.JedisCluster.<init>(JedisCluster.java:)
at com.xwood.redis.cluster.JedisClusterTest.main(JedisClusterTest.java:)
客户端代码示例如下:
package com.xwood.redis.cluster;
import java.util.HashSet;
import java.util.Set;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
public class JedisClusterTest {
public static void main(String[] args) {
Set<HostAndPort> nodes = new HashSet<HostAndPort>();
nodes.add(new HostAndPort("192.168.1.204", ));
nodes.add(new HostAndPort("192.168.1.204", ));
nodes.add(new HostAndPort("192.168.1.204", ));
nodes.add(new HostAndPort("192.168.1.204", ));
nodes.add(new HostAndPort("192.168.1.204", ));
nodes.add(new HostAndPort("192.168.1.204", ));
JedisCluster cluster = new JedisCluster(nodes);
cluster.set("key424", "");
String result = cluster.get("key424");
System.out.println("cluster=========>"+result);
cluster.close();
}
}
二、解决方法
因jedis-2.7.0.jar版本问题,改为jedis-3.0.1.jar版本就能解决问题,因为redis5.0版本需要客户端相应高版本驱动包
解决测试redis集群时报"java.lang.NumberFormatException: For input string: "7003@17003..7002@17002"等异常的更多相关文章
- Redis集群环境使用的是redis4.0.x的版本,在用java客户端jedisCluster启动集群做数据处理时报java.lang.NumberFormatException: For input string: "7003@17003"问题解决
java.lang.NumberFormatException: For input string: "7003@17003" at java.lang.NumberFormatE ...
- maven项目中使用redis集群报错: java.lang.NumberFormatException: For input string: "7006@17006"
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [redis.client ...
- 执行Hive时出现org.apache.hadoop.util.RunJar.main(RunJar.java:136) Caused by: java.lang.NumberFormatException: For input string: "1s"错误的解决办法(图文详解)
不多说,直接上干货 问题详情 [kfk@bigdata-pro01 apache-hive--bin]$ bin/hive Logging initialized -bin/conf/hive-log ...
- 解决java.lang.NumberFormatException: For input string: "id"
今天,项目突然报"java.lang.NumberFormatException:For input string:"id"",项目框架是spring,spri ...
- SpringBoot整合Swagger2案例,以及报错:java.lang.NumberFormatException: For input string: ""原因和解决办法
原文链接:https://blog.csdn.net/weixin_43724369/article/details/89341949 SpringBoot整合Swagger2案例 先说SpringB ...
- Swagger2异常 java.lang.NumberFormatException: For input string: ""
问题在访问swagger首页时报错: java.lang.NumberFormatException: For input string: "" at java.lang.Numb ...
- mybatis 报错:Caused by: java.lang.NumberFormatException: For input string
mybatis的if标签之前总是使用是否为空,今天要用到字符串比较的时候遇到了困难,倒腾半天,才在一个论坛上找到解决方法.笔记一下,如下: 转自:https://code.google.com/p/m ...
- Caused by: java.lang.NumberFormatException: For input string: "18446744073709551615"
问题:Caused by: java.lang.NumberFormatException: For input string: "18446744073709551615" 原因 ...
- java.lang.NumberFormatException: For input string: "${jdbc.maxActive}"
一.问题 使用SpringMVC和MyBatis整合,将jdbc配置隔离出来的时候出现下面的错误,百度了很久没有找到解决方法,回家谷歌下,就找到解决方法了,不得不说谷歌就是强大,不废话,下面是具体的错 ...
随机推荐
- lodash.memoize
目录 _.memoize(func, [resolver]) 举例1: 获取J(1000000)的值 举例2: 斐波那契数列F(1000)的值 _.memoize(func, [resolver]) ...
- Python字符串学习
Python字符串(不可变的): 一.相关的运算: 1.字符串的拼接: str = str1 + str2 2.字符串的重复: print(str * 3) 3.下标访问字符串某个字符: str[1] ...
- Zookeeper Watcher接口
在ZooKeeper中,接口类Watcher用于表示一个标准的事件处理器,其定义了事件通知相关的逻辑,包含KeeperState和EventType两个枚举类,分别代表了通知状态和事件类型,同时定义了 ...
- 2017 ACM/ICPC 沈阳 I题 Little Boxes
Little boxes on the hillside. Little boxes made of ticky-tacky. Little boxes. Little boxes. Little b ...
- NIO-Channel接口分析
目录 NIO-Channel源码分析 目录 前言 接口 SCTP协议 UDP协议 TCP协议 文件 总结 相关文献 NIO-Channel源码分析 目录 NIO-概览 NIO-Buffer NIO-C ...
- 这3步简单搭建Python http服务器 你肯定不会吧?
前言 本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 作者:stark张宇 趁着周末的闲暇时光看看Python是什么鬼 给疲倦的 ...
- textarea增加字数监听且高度自适应(兼容IE8)
1.封装方法: var textareaListener = { /*事件监听器兼容 * *attachEvent——兼容:IE7.IE8:不兼容firefox.chrome.IE9.IE10.IE1 ...
- SSM-配置tkmybatis
引言 Mybatis 与 Hibernate的一个很大的区别就是Mybatis所有的数据库操作语句都需要自己写,对于简单的单表操作来说是比较烦琐的.因此有人就开发了tk.mybatis插件,通过这个插 ...
- django----orm查询优化 MTV与MVC模型 choice参数 ajax serializers
目录 orm查询优化 only defer select_related 与 prefetch_related MTV 与 MVC 模型 choice参数 Ajax 前端代码 后端代码 前后端传输数据 ...
- Java使用ObjectMapper做数据转换的常用工具类实现
1.介绍 ObjectMapper类是Jackson库的主要类,它提供一些功能将数据集或对象转换的实现 2.依赖包 <!-- https://mvnrepository.com/artifact ...