edis时收到JedisConnection的NoClassDe

edis时收到JedisConnection的NoClassDe

本文介绍了为什么在使用Spring Redis时收到JedisConnection的NoClassDefFound错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,当我尝试使用spring-redis时

Hello when trying to use spring-redis i am getting

java.lang.NoClassDefFoundError: Could not initialize class org.springframework.data.redis.connection.jedis.JedisConnection

使用Redis进行任何连接操作时,

例外.我的配置方法是这样

exception when doing any connection operation using redis. My config method goes like this

 @Bean
public RedisConnectionFactory jedisConnFactory() {
    JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();

    jedisConnectionFactory.setHostName("XXX.XX.XX.XXX");

    jedisConnectionFactory.setPort(6381);
    jedisConnectionFactory.setUsePool(true);
    jedisConnectionFactory.afterPropertiesSet();
    return jedisConnectionFactory;

请建议是否有人知道我为什么收到此例外.

Please suggest if anyone knows why i am getting this exception.

推荐答案

浪费了将近一天的时间后,发现jar已经在我的类路径中,我进一步对其进行了调试,发现当java的反射机制试图找到一个jar时,由于 Jedis版本(2.7.2)与Spring Data Redis(1.5.0.RELEASE)不兼容之间存在版本冲突,因此无法在方法列表"中找到该方法,此问题已在此链接中得到解答:::
Jedis和spring数据redis版本冲突

After wasting almost one day and finding that the jar is already on my class path, i further debugged it and found that when java's reflection mechanism was trying to find a method which was already present in the "methods list" it was not able to find due to some version conflict between Jedis version (2.7.2) not compatible with Spring Data Redis (1.5.0.RELEASE) , this issue has already been answered in this link ::
Jedis and spring data redis version conflict

这篇关于为什么在使用Spring Redis时收到JedisConnection的NoClassDefFound错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 17:06