2 qq 29906709 qq_29906709 于 2016.02.02 11:49 提问

commons-pool2实现redis集群,报JedisDataException异常

配置文件如下:

 <bean id="genericObjectPoolConfig" class="org.apache.commons.pool2.impl.GenericObjectPoolConfig">
        <property name="maxTotal" value="${redis.maxActive}"></property>
        <property name="maxIdle" value="${redis.maxIdle}"/>
        <property name="maxWaitMillis" value="${redis.maxWait}"/>
        <property name="testOnBorrow" value="${redis.testOnBorrow}"/>
        <property name="testOnReturn" value="${redis.testOnReturn}"/>
    </bean>
    <bean id="jedisCluster" class="com.kongkong.util.JedisClusterFactory">
        <property name="addressConfig">
            <value>classpath:kongkong.properties</value>
        </property>
        <property name="addressKeyPrefix" value="address"/>
        <property name="timeout" value="300000"/>
        <property name="maxRedirections" value="6"/>
        <property name="genericObjectPoolConfig" ref="genericObjectPoolConfig"/>
    </bean>

异常如下:

 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jedisCluster' defined in URL [file:/C:/Work/kongkong/WebRoot/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is redis.clients.jedis.exceptions.JedisDataException: ERR unknown command 'CLUSTER'
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1488)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:910)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:853)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:768)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:486)
    ... 70 more
Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR unknown command 'CLUSTER'
    at redis.clients.jedis.Protocol.processError(Protocol.java:117)
    at redis.clients.jedis.Protocol.process(Protocol.java:151)
    at redis.clients.jedis.Protocol.read(Protocol.java:205)
    at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:297)
    at redis.clients.jedis.Connection.getBinaryBulkReply(Connection.java:216)
    at redis.clients.jedis.Connection.getBulkReply(Connection.java:205)
    at redis.clients.jedis.Jedis.clusterNodes(Jedis.java:3203)
    at redis.clients.jedis.JedisClusterInfoCache.discoverClusterNodesAndSlots(JedisClusterInfoCache.java:48)
    at redis.clients.jedis.JedisClusterConnectionHandler.initializeSlotsCache(JedisClusterConnectionHandler.java:39)
    at redis.clients.jedis.JedisClusterConnectionHandler.<init>(JedisClusterConnectionHandler.java:28)
    at redis.clients.jedis.JedisSlotBasedConnectionHandler.<init>(JedisSlotBasedConnectionHandler.java:21)
    at redis.clients.jedis.JedisSlotBasedConnectionHandler.<init>(JedisSlotBasedConnectionHandler.java:16)
    at redis.clients.jedis.BinaryJedisCluster.<init>(BinaryJedisCluster.java:39)
    at redis.clients.jedis.JedisCluster.<init>(JedisCluster.java:45)
    at com.kongkong.util.JedisClusterFactory.afterPropertiesSet(JedisClusterFactory.java:82)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1547)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1485)
    ... 80 more

报错行如下:
jedisCluster = new JedisCluster(haps, timeout, maxRedirections,genericObjectPoolConfig);

2个回答

rui888
rui888   Ds   Rxr 2016.02.02 12:01
qq_29906709
qq_29906709   2016.02.02 13:54

有大神在吗?谁来帮帮我

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!