概述
springboot中使用spring-data-redis出现Caused by: java.lang.ClassNotFoundException: redis.clients.jedis.JedisPoolConfig
在maven的配置如下:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.0.4.RELEASE</version>
</dependency>
启动测试类的时候,总是出现如下异常;
Caused by: java.lang.NoClassDefFoundError: redis/clients/jedis/JedisPoolConfig
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3139)
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2266)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:641)
... 78 more
Caused by: java.lang.ClassNotFoundException: redis.clients.jedis.JedisPoolConfig
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1309)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1138)
... 82 more
解决:
修改成如下配置:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<exclusions>
<exclusion>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
为什么?看友人翻译
JedisPoolConfig is needed when we use Jedis Configuration. In Spring Boot 2.0, spring-boot-starter-data-redis gives Lettuce dependency by default instead of Jedis. To use Jedis configuration, exclude Lettuce and add Jedis as following.
原文链接: https://www.concretepage.com/questions/599
最后
以上就是机灵小猫咪为你收集整理的问题已解决 Caused by: java.lang.ClassNotFoundException: redis.clients.jedis.JedisPoolConfig的全部内容,希望文章能够帮你解决问题已解决 Caused by: java.lang.ClassNotFoundException: redis.clients.jedis.JedisPoolConfig所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复