Tag Archives: SpringBoot Access Redis Error

[Solved] SpringBoot Access Redis Error: java.lang.NoSuchMethodError: redis.clients.jedis.JedisPoolConfig.setMinEvictableIdleTime

Complete error reporting information:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed;
nested exception is java.lang.NoSuchMethodError: redis.clients.jedis.JedisPoolConfig.setMinEvictableIdleTime(Ljava/time/Duration;)V] with root cause

java.lang.NoSuchMethodError: redis.clients.jedis.JedisPoolConfig.setMinEvictableIdleTime(Ljava/time/Duration;)V

Reason 1:

Other components in Maven depend on the old version of jedis and need to be excluded

Solution to cause 1:

In <dependency></dependency> Add and exclude the dependency of old jedis

<exclusions>
    <exclusion>
        <groupId>redis.clients</groupId>
        <artifactId>jedis</artifactId>
    </exclusion>
</exclusions>

Reload Maven’s dependent components and run them again.

Reason 2:

Jedispoolconfig and jedissentinelpool use Apache Commons-pool2 package for Commons

Although no error will be reported when compiling the code, the runtime will prompt that the package cannot be found. (suspected to be the reason for using reflection)

Solution to cause 2:

In POM XML <dependencies></dependencies> Add the following configuration to the:

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-pool2</artifactId>
    <version>2.11.1</version>
</dependency>

Reload Maven’s dependent components and run them again.