为什么在使用 Spring Redis 时 JedisConnection 出现 NoClassDefFound 错误 [英] Why Getting NoClassDefFound error for JedisConnection when using Spring Redis
问题描述
你好,当我尝试使用 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已经在我的class路径上,我进一步调试,发现当java的反射机制试图找到一个由于 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 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!