一、前言

关于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"等异常的更多相关文章

  1. 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 ...

  2. maven项目中使用redis集群报错: java.lang.NumberFormatException: For input string: "7006@17006"

    Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [redis.client ...

  3. 执行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 ...

  4. 解决java.lang.NumberFormatException: For input string: "id"

    今天,项目突然报"java.lang.NumberFormatException:For input string:"id"",项目框架是spring,spri ...

  5. SpringBoot整合Swagger2案例,以及报错:java.lang.NumberFormatException: For input string: ""原因和解决办法

    原文链接:https://blog.csdn.net/weixin_43724369/article/details/89341949 SpringBoot整合Swagger2案例 先说SpringB ...

  6. Swagger2异常 java.lang.NumberFormatException: For input string: ""

    问题在访问swagger首页时报错: java.lang.NumberFormatException: For input string: "" at java.lang.Numb ...

  7. mybatis 报错:Caused by: java.lang.NumberFormatException: For input string

    mybatis的if标签之前总是使用是否为空,今天要用到字符串比较的时候遇到了困难,倒腾半天,才在一个论坛上找到解决方法.笔记一下,如下: 转自:https://code.google.com/p/m ...

  8. Caused by: java.lang.NumberFormatException: For input string: "18446744073709551615"

    问题:Caused by: java.lang.NumberFormatException: For input string: "18446744073709551615" 原因 ...

  9. java.lang.NumberFormatException: For input string: "${jdbc.maxActive}"

    一.问题 使用SpringMVC和MyBatis整合,将jdbc配置隔离出来的时候出现下面的错误,百度了很久没有找到解决方法,回家谷歌下,就找到解决方法了,不得不说谷歌就是强大,不废话,下面是具体的错 ...

随机推荐

  1. BZOJ 3065 带插入区间K小值(sag套线段树)

    3065: 带插入区间K小值 Time Limit: 60 Sec  Memory Limit: 512 MBSubmit: 4696  Solved: 1527[Submit][Status][Di ...

  2. Remember the Word (UVA-1402)

    Neal is very curious about combinatorial problems, and now here comes a problem about words. Knowing ...

  3. ARTS-S pytorch用c++实现推理

    训练的代码,以cifar为例 # -*- coding: utf-8 -*- import torch import torchvision import torchvision.transforms ...

  4. 使用SQL计算宝宝每次吃奶的时间间隔(续)

    本文是<使用SQL计算宝宝每次吃奶的时间间隔>的续篇,因为我工作繁忙,时常不能及时帮助媳妇儿记录,为了让不懂数据库的媳妇儿也可以自己用手机熟练操作.我继续做了一些修正和封装: 1.给媳妇儿 ...

  5. 记录我的 python 学习历程-Day06 is id == / 代码块 / 集合 / 深浅拷贝

    一.is == id 用法 在Python中,id是内存地址, 你只要创建一个数据(对象)那么就会在内存中开辟一个空间,将这个数据临时加载到内存中,这个空间有一个唯一标识,就好比是身份证号,标识这个空 ...

  6. Day 08 作业

    有如下值集合 [11, 22, 33, 44, 55, 66, 77, 88, 99, 90...],将所有大于 66 的值保存至字典的第一个key中,将小于 66 的值保存至第二个key的值中 ​ ...

  7. vue中$attrs和$listeners以及inheritAttrs的用法

    官方文档说明: 一.解释:包含了父作用域中不作为 prop 被识别 (且获取) 的特性绑定 (class 和 style 除外). 意思就是父组件往子组件传没有在props里声明过的值时,子组件可以通 ...

  8. webpack学习_webpack-dev-server自动编译代码

    之前每次修改完之后都要执行npm run build来编译,下面有三种方式可以实现代码变化后自动编译代码,下面只重点说webpack-dev-server,其他的请看webpack开发文档 1.web ...

  9. 《Android项目实战--手机安全卫士》读后感

    上学期在学校图书馆看到此书,觉得比较贴近实践,于是寒假研究了一番,也算是体会了一把社会培训机构的模式. 由于时间关系,最后两章还没弄完,但感觉每章节的流程相似,加之马上要回学校了,所以打算在家的最后一 ...

  10. 新手如何快速入门node.js

    附Java/C/C++/机器学习/算法与数据结构/前端/安卓/Python/程序员必读书籍书单大全: 书单导航页(点击右侧 极客侠栈 即可打开个人博客):极客侠栈 ①[Java]学习之路吐血整理技术书 ...