当前位置:  开发笔记 > 编程语言 > 正文

JedisPoolConfig不能分配给GenericObjectPoolConfig

如何解决《JedisPoolConfig不能分配给GenericObjectPoolConfig》经验,为你挑选了1个好方法。

我有一个在Heroku上托管的基于Spring的java Web应用程序.我试图使用Redis实现来利用Spring Caching抽象.当服务器启动时,我收到一条错误消息:

Type 'redis/clients/jedis/JedisPoolConfig' (current frame, stack[3]) is not assignable to 'org/apache/commons/pool2/impl/GenericObjectPoolConfig'

这是我的配置:

@Bean
     RedisConnectionFactory jedisConnectionFactory() throws Exception {
         URI redisUri =  new URI(System.getenv("REDISCLOUD_URL"));
         JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();
         redisConnectionFactory.setHostName(redisUri.getHost());
         redisConnectionFactory.setPort(redisUri.getPort());
         redisConnectionFactory.setPassword(redisUri.getUserInfo().split(":",2)[1]);
         redisConnectionFactory.setUsePool(true);
         return redisConnectionFactory;
     }

 @Bean
 RedisTemplate redisTemplate()  {
     RedisTemplate redisTemplate = new RedisTemplate();
     try {
        redisTemplate.setConnectionFactory(jedisConnectionFactory());
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
     return redisTemplate;
 }
@Override
@Bean
public CacheManager cacheManager() {
    // configure and return an implementation of Spring's CacheManager SPI
    RedisCacheManager manager = new RedisCacheManager(redisTemplate());
    List caches = new ArrayList();
    caches.add("Suppliers");
    caches.add("Manufacturer");
    caches.add("Sheeting");
    caches.add("SignTypeFlat");
    manager.setCacheNames(caches);
    return manager;
}

这是整个错误消息:

 Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory m ethod [org.springframework.data.redis.connection.RedisConnectionFactory com.signInventory.config.ProdDataSourceConfiguration.jedisConnectionFactory() throws java.lang.Exception] threw exception; nested exception is java.lang.VerifyError: Bad type on operand stack Exception Details:   Location:
    org/springframework/data/redis/connection/jedis/JedisConnectionFactory.afterPropertiesSet()V @109: invokespecial   Reason:
    Type 'redis/clients/jedis/JedisPoolConfig' (current frame, stack[3]) is not assignable to 'org/apache/commons/pool2/impl/GenericObjectPoolConfig'   Current Frame:
    bci: @109
    flags: { }
    locals: { 'org/springframework/data/redis/connection/jedis/JedisConnectionFactory' }
    stack: { 'org/springframework/data/redis/connection/jedis/JedisConnectionFactory', uninitialized 73, uninitialized 73, 'redis/clients/jedis/JedisPoolConfig', 'java/lang/String', integer, integer, 'java/lang/String' }   Bytecode:
    0000000: 2ab4 000d c700 3d2a bb00 1759 2ab4 0003
    0000010: 2ab4 0004 b700 18b5 000d 2ab4 0019 b800
    0000020: 1a99 000e 2ab4 000d 2ab4 0019 b600 1b2a
    0000030: b400 059e 000e 2ab4 000d 2ab4 0005 b600
    0000040: 1c2a b400 0699 002e 2abb 001d 592a b400
    0000050: 0a2a b400 0db6 001e 2ab4 000d b600 1f2a
    0000060: b400 0db6 0020 2ab4 000d b600 21b7 0022
    0000070: b500 07b1   Stackmap Table:
    same_frame(@47)
    same_frame(@65)
    same_frame(@115) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:181) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:578) ... 36 more Caused by: java.lang.VerifyError: Bad type on operand stack Exception Details:   Location:
    org/springframework/data/redis/connection/jedis/JedisConnectionFactory.afterPropertiesSet()V @109: invokespecial   Reason:
    Type 'redis/clients/jedis/JedisPoolConfig' (current frame, stack[3]) is not assignable to 'org/apache/commons/pool2/impl/GenericObjectPoolConfig'   Current Frame:
    bci: @109
    flags: { }
    locals: { 'org/springframework/data/redis/connection/jedis/JedisConnectionFactory' }
    stack: { 'org/springframework/data/redis/connection/jedis/JedisConnectionFactory', uninitialized 73, uninitialized 73, 'redis/clients/jedis/JedisPoolConfig', 'java/lang/String', integer, integer, 'java/lang/String' }   Bytecode:
    0000000: 2ab4 000d c700 3d2a bb00 1759 2ab4 0003
    0000010: 2ab4 0004 b700 18b5 000d 2ab4 0019 b800
    0000020: 1a99 000e 2ab4 000d 2ab4 0019 b600 1b2a
    0000030: b400 059e 000e 2ab4 000d 2ab4 0005 b600
    0000040: 1c2a b400 0699 002e 2abb 001d 592a b400
    0000050: 0a2a b400 0db6 001e 2ab4 000d b600 1f2a
    0000060: b400 0db6 0020 2ab4 000d b600 21b7 0022
    0000070: b500 07b1   Stackmap Table:
    same_frame(@47)
    same_frame(@65)
    same_frame(@115) at com.signInventory.config.ProdDataSourceConfiguration.jedisConnectionFactory(ProdDataSourceConfiguration.java:46) at com.signInventory.config.ProdDataSourceConfiguration$$EnhancerByCGLIB$$258faa2b.CGLIB$jedisConnectionFactory$8() at com.signInventory.config.ProdDataSourceConfiguration$$EnhancerByCGLIB$$258faa2b$$FastClassByCGLIB$$b4f3aedd.invoke() at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:286) at com.signInventory.config.ProdDataSourceConfiguration$$EnhancerByCGLIB$$258faa2b.jedisConnectionFactory() at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:160) ... 37 more

任何帮助将不胜感激.

谢谢!



1> spilio..:

当我升级到Spring Data Redis v1.2.1-RELEASE时遇到了完全相同的问题.我将Jedis升级到最新版本--v2.4.2后解决了这个问题.如果您使用的是Maven,请检查以下依赖项.


    1.2.1.RELEASE
    2.4.2



    org.springframework.data
    spring-data-redis
    ${spring.data.redis}


    redis.clients
    jedis
    ${jedis}

希望这可以帮助 :)

推荐阅读
手机用户2402852307
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有