Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

Migrating spring-boot-redis and Jedis to use Jedis 4.2

$
0
0

I have an application running older version of Spring Boot and Jedis, and would wish to upgrade to more recent versions so 2.7.3. for org.springframework.boot.spring-boot-starter-data-redis and 4.2.3 for redis.clients.jedis. This is my code with older Jedis.

@BeanJedisConnectionFactory jedisConnectionFactory() {    return new JedisConnectionFactory(new RedisStandaloneConfiguration(this.endpoint, this.port));}@Beanpublic RedisTemplate<String, String> redisTemplate() {    final RedisTemplate<String, String> template = new RedisTemplate<>();    template.setConnectionFactory(jedisConnectionFactory());    template.setKeySerializer(new StringRedisSerializer());    template.setHashValueSerializer(new GenericToStringSerializer<>(Serializable.class));    template.setValueSerializer(new GenericToStringSerializer<>(Serializable.class));    return template;}

However with upgrading Spring Boot and 4.x Jedis, I'm getting the following error

class file for redis.clients.jedis.JedisShardInfo not found

Jedis 3 to Jedis 4 Breaking Changes -document gives that JedisShardInfo indeed was removed from the Jedis code, and there are classes to replace that one. However, JedisConnectionFactory from org.springframework.data.redis.connection.jedis still seems to use JedisShardInfo-class internally, so coupling spring-boot-redis 2.7.3. with Jedis 4.x seems to lead into this scenario, at least when initializing the class with JedisConnectionFactory.

So what I'm wondering here is how should I couple spring-boot-redis with the newest Jedis 4.x to get it running with the RedisTemplate.


Viewing all articles
Browse latest Browse all 2204

Trending Articles