一、前言

关于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. UILabel(label控件)的详细使用及特殊效果

    转自:http://blog.sina.com.cn/s/blog_af73e7a70101ahlm.html UILabel *label = [[UILabelalloc] initWithFra ...

  2. lodash.memoize

    目录 _.memoize(func, [resolver]) 举例1: 获取J(1000000)的值 举例2: 斐波那契数列F(1000)的值 _.memoize(func, [resolver]) ...

  3. poj3111 K Best 最大化平均值,二分

    题目:http://poj.org/problem?id=3111 题意:给你n,k,n个数的v.w值,选出k个数,使得v之和/w之和最大化. 思路:一看到题目,这不是赤果果的贪心吗?为什么放在二分专 ...

  4. ARTS-S ansible-playbook

    文件a.yml --- - hosts: cluster remote_user: ksotest gather_facts: false tasks: - name: delete dir if e ...

  5. 小白进阶之路—python脚本(1)判断是否是一个目录

    #!/usr/bin/env python# -*- coding: utf-8 -*-import os   dir = "/var/www/html/EnjoyWeekend/" ...

  6. linux自定义开机欢迎页面图案

    1:编辑etc目录下motd文件 佛祖图案 [root@host1 ~]# vim /etc/motd _oo0oo_ 088888880 88" . "88 (| -_- |) ...

  7. 2019年JVM面试都问了什么?快看看这22道面试题!(附答案解析)

    一. Java 类加载过程? Java 类加载需要经历一下 7 个过程: 1. 加载 加载是类加载的第一个过程,在这个阶段,将完成一下三件事情: • 通过一个类的全限定名获取该类的二进制流. • 将该 ...

  8. 服务器上无法调用Office组件的解决方法(HRESULT:0X800A03EC异常)

    HRESULT:0X800A03EC的异常,经过多番查找,终于找到了解决方法,在 Windows 2008 中, 如果以 SYSTEM 用户跑, 系统会去寻找 SYSTEM 这个用户的 Profile ...

  9. 《MySQL数据库》MySQL数据库安装(linux)

    1.  下载安装包: 百度网盘:链接: https://pan.baidu.com/s/1toGl8O9gMBpDWn0mHWwFyg 提取码: i51g 官网下载:https://dev.mysql ...

  10. C# WPF抽屉效果实现(C# WPF Material Design UI: Navigation Drawer & PopUp Menu)

    时间如流水,只能流去不流回! 点赞再看,养成习惯,这是您给我创作的动力! 本文 Dotnet9 https://dotnet9.com 已收录,站长乐于分享dotnet相关技术,比如Winform.W ...