我有一个应用程序正在运行较早版本的Spring和Jedis,并且希望升级到更新的版本,以便2.7.3。用于org.springframework.boot.spring-boot-starter-data-redis和4.2.3用于redis.clients.jedis。这是我和老杰迪斯的代码。
@Bean
JedisConnectionFactory jedisConnectionFactory() {
return new JedisConnectionFactory(new RedisStandaloneConfiguration(this.endpoint, this.port));
}
@Bean
public 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;
}然而,通过升级Spring和4.xJedis,我得到了以下错误
class file for redis.clients.jedis.JedisShardInfo not foundJedis 3到Jedis 4打破更改 -document给出了JedisShardInfo确实被从Jedis代码中删除了,并且有一些类可以替换这个类。然而,org.springframework.data.redis.connection.jedis的JedisConnectionFactory似乎仍然在内部使用JedisShardInfo类,因此耦合spring redis 2.7.3。使用Jedis 4.x似乎会导致这种情况,至少在用JedisConnectionFactory初始化类时是如此。
因此,我在这里想知道的是,我应该如何将spring redis与最新的Jedis 4.x结合起来,让它与RedisTemplate一起运行。
发布于 2022-09-30 18:02:49
Jedis 4支持的目标是Spring3.0。如果您真的想使用Jedis 4.x,请使用Spring3.0快照或里程碑版本。否则,继续使用Jedis 3.x。
https://stackoverflow.com/questions/73911106
复制相似问题