问题已解决 Caused by: java.lang.ClassNotFoundException: redis.clients.jedis.JedisPoolConfig
springboot中使用spring-data-redis出现Caused by: java.lang.ClassNotFoundException: redis.clients.jedis.JedisPoolConfig在maven的配置如下:<dependency><groupId>org.springframework.boot</gr...
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
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)