class file for redis.clients.jedis.JedisShardInfo not found
Asked Answered
K

4

5

when I upgrade the jedis to version 4.2.3 in gradle.build:

    api "redis.clients:jedis:4.2.3"

show error:

/Users/xiaoqiangjiang/source/reddwarf/backend/retire/dolphin-common/src/main/java/misc/config/redis/RedisConfig.java:77: error: cannot access JedisShardInfo
        return new JedisConnectionFactory(redisConfig);
               ^
  class file for redis.clients.jedis.JedisShardInfo not found

this is the redis config:

    @Bean
    public JedisConnectionFactory redisConnectionFactory() {
        var redisConfig = new RedisStandaloneConfiguration(redisHost, redisPort);
        redisConfig.setPassword(redisPwd);
        return new JedisConnectionFactory(redisConfig);
    }

why did this error happen? what should I do to fix it? I have searched from google seems no one facing this problem.

Karlene answered 10/5, 2022 at 13:58 Comment(0)
D
5

The class JedisShardInfo is removed since Jedis 4.

The ShardedJedisPool, Sharded, ShardedJedis, BinaryShardedJedis, ShardInfo, JedisShardInfo classes have been removed.

Here is the list of all breaking changes between Jedis 3.x and Jedis 4.x.

Diocletian answered 10/5, 2022 at 14:27 Comment(1)
ok, but why newest spring-data-redis 2.6.4 JedisConnectionFactory, still uses JedisShardInfo ... ? error: cannot access JedisShardInfo return new JedisConnectionFactory(connectionConfig);Larceny
A
5

Use this dependency 3.9.0 or less version, because Some of the classes have been removed in the new version.

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

Note: SNAPSHOT, M1, M2, M3, and M4 releases typically WORK IN PROGRESS. The Spring team is still working on them, Recommend NOT using them.

Aishaaisle answered 21/9, 2022 at 6:12 Comment(0)
J
1

Some of the classes have been removed, so use Jedis version: 3.9.0

Janitress answered 29/6, 2022 at 11:1 Comment(0)
P
0

change the verion as per below

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.6.1</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.redis.sprinboot</groupId>
<artifactId>redis-springboot-mysql</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>redis-springboot-mysql</name>
<description>Demo project for Spring Boot</description>
<properties>
    <java.version>17</java.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>
    <dependency>
        <groupId>redis.clients</groupId>
        <artifactId>jedis</artifactId>
        <version>3.9.0</version>
    </dependency>
    
</dependencies>
Pumping answered 2/2 at 12:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.