问题已解决 Caused by: java.lang.ClassNotFoundException: redis.clients.jedis.JedisPoolConfig

 

springboot中使用spring-data-redis出现Caused by: java.lang.ClassNotFoundException: redis.clients.jedis.JedisPoolConfig

在maven的配置如下:

   org.springframework.boot

   spring-boot-starter-data-redis

   2.0.4.RELEASE

    

启动测试类的时候,总是出现如下异常;

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

 

解决:

修改成如下配置:


  org.springframework.boot
  spring-boot-starter-data-redis
 
   
     io.lettuce
     lettuce-core
   

 
            
        

  redis.clients
  jedis
 

 

为什么?看友人翻译

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

 

你可能感兴趣的:(gradle,gradle)