Why Getting NoClassDefFound error for JedisConnection when using Spring Redis

latest version that Redis client still keeps old package structure is: 2.10.2.

<dependency>
    <groupId>redis.clients</groupId>
    <artifactId>jedis</artifactId>
    <version>2.10.2</version>
</dependency>

From 3.0.x, package structure has been changed. if spring-data-redis invokes Pool class of redis client with old package structure, then java.lang.NoClassDefFoundError

seems latest spring-data-redis: 2.1.10.RELEASE still invokes Pool class of redis client with old package structure so you need to use redis.clients 2.10.2


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


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.

<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>

latest version of Redis client solved my issue.

<dependency>
    <groupId>redis.clients</groupId>
    <artifactId>jedis</artifactId>
    <version>3.6.0</version>
</dependency>

Tags:

Java

Spring

Redis