一、前言

关于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. GRPC的metadata使用

    文章目录 一.简析 1.创建metadata 2.发送metadata 3.接收metadata 二.代码举例 1.proto文件编写 2.server端编写 3.client端编写 三.实际使用举例 ...

  2. openstack网络(四)-虚机流量分析

    几种网络名词解释 使用LinuxBridge时虚机流量分析 VLAN FLAT Local VXLAN 使用OVS时虚机流量分析 几种网络名词解释 1.local网络:local网络是与其他网络和节点 ...

  3. 使用.NET Core创建Windows服务 - 使用.NET Core工作器方式

    原文:Creating Windows Services In .NET Core – Part 3 – The ".NET Core Worker" Way 作者:Dotnet ...

  4. 回文自动机pam

    目的:类似回文Trie树+ac自动机,可以用来统计一些其他的回文串相关的量 复杂度:O(nlogn) https://blog.csdn.net/Lolierl/article/details/999 ...

  5. HDU4670 cube number on a tree(点分治+三进制加法)

    The country Tom living in is famous for traveling. Every year, many tourists from all over the world ...

  6. ARTS-S 最难的事情

    小朋友不舒服,看了医生也开了药吃了.但还是一直闹,不睡觉,弄的我和我爱人精疲力尽. 现在看来,技术上的难题真不算什么.照顾小朋友才是这个世界上最难的事情.

  7. todo demo

    Todo 功能实现 https://rencoo.github.io/appDemo/todo/index.html ---1.添加事项 ---2.置顶事项 ---3.删除事项 ---4.用时排序 - ...

  8. JavaEE基础(06):Servlet整合C3P0数据库连接池

    本文源码:GitHub·点这里 || GitEE·点这里 一.C3P0连接池 1.C3P0简介 C3P0是一个开源的JDBC连接池,应用程序根据C3P0配置来初始化数据库连接,可以自动回收空闲连接的功 ...

  9. GHOST CMS - 配置 Config

    Config For self-hosted Ghost users, a custom configuration file can be used to override Ghost's defa ...

  10. cesium计算当前地图范围extent以及近似当前层级zoom

    前言 cesium 官网的api文档介绍地址cesium官网api,里面详细的介绍 cesium 各个类的介绍,还有就是在线例子:cesium 官网在线例子,这个也是学习 cesium 的好素材. 内 ...