一、前言

关于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. git 使用详解(3)—— 最基本命令 + .gitignore 文件

    Git 基础 本章将介绍几个最基本的,也是最常用的 Git 命令,以后绝大多数时间里用到的也就是这几个命令.读完本章,你就能初始化一个新的代码仓库,做一些适当配置:开始或停止跟踪某些文件:暂存或提交某 ...

  2. python实现十大核心算法(桶排没实例)

    # author:sevenduke # 2019-06-11 # 一.交换排序 # 排序算法的温故:冒泡排序 def dubblesort(arr): for i in range(0, len(a ...

  3. acm模板总结

    模板链接 字符串模板 KMP EXKMP Trie 可持久化Trie树+DFS序 01Trie Manacher 字符串哈希 2019上海网络赛G题 17 SA(后缀数组)  最大不重叠相似子串 求两 ...

  4. ARTS-S sed指定行添加

    sed -i 's#^AAAA.*#&BBBB#g' a.txt 在以AAA开始的行懂添加BBBB

  5. Python如何实现微信群万人同步直播?

    很多人传言微信网页版(https://wx.qq.com/)接口已经被封了,所以所有的微信都不能登录网页版,这是错误的. 2019年7月微信对网页版微信进行了动态安全策略调整,导致一大批微信号不能登录 ...

  6. ES6语法中的class、extends与super的原理

    class 首先, 在JavaScript中, class类是一种函数 class User {    constructor(name) { this.name = name; }    sayHi ...

  7. irules

    BIG-IP系统iRules基本概念_v11.6.1 2017年10月10日 00:35:16 ifelif 阅读数:1097   1 iRules介绍 什么是iRule iRule是BIG-IP本地 ...

  8. win10 修改用户目录为英文

    win10家庭版怎样进入 administratornet user administrator /active:yes net user administrator /active:no

  9. Java 复制Excel工作表

    本文归纳了关于Java如何复制Excel工作表的方法,按不同复制需求,可分为: 1. 复制工作表 1.1 在同一个工作簿内复制工作表 1.2 在不同工作簿间复制工作表 2. 复制指定单元格数据 对于复 ...

  10. HyperLedger Fabric 1.4 生产环境动态添加组织及节点

    网易云课堂视频在线教学,地址:https://study.163.com/course/introduction/1209401942.htm 1.1 操作概述      在“kafka生产环境部署” ...