I have my RedisConfig class as:
@EnableRedisRepositories
public class RedisConfig {
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration();
return new JedisConnectionFactory(redisStandaloneConfiguration);
}
@Bean
public RedisTemplate<String, Object> redisTemplate() {
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(jedisConnectionFactory());
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.setHashKeySerializer(new JdkSerializationRedisSerializer());
redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
redisTemplate.setEnableTransactionSupport(true);
redisTemplate.afterPropertiesSet();
return redisTemplate;
}
}
When I try to build it I am facing the following issue:
ava: cannot access redis.clients.jedis.JedisPoolConfig
class file for redis.clients.jedis.JedisPoolConfig not found
Now, what I tried is I removed the redisStandaloneConfiguration from JedisConnectionFactory and just returned new new JedisConnectionFactory().
Although, I am not getting the above error, I am facing a new one:
Error creating bean with name 'jedisConnectionFactory' defined in class path resource [com/iplbetting/iplbettingtracker/config/RedisConfig.class]: Failed to instantiate [org.springframework.data.redis.connection.jedis.JedisConnectionFactory]: Factory method 'jedisConnectionFactory' threw exception with message: redis/clients/jedis/JedisClientConfig
When I inspect further, it's caused by java.lang.ClassNotFoundException: redis.clients.jedis.JedisClientConfig
I am using spring-boot-starter-data-redis, although I tried adding the jedis library with version 3.x, I was still facing the same issue.
Here are the dependencies in my pom.xml:
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<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>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.7.2</version>
</dependency>-->
</dependencies>
Is there any configuration i am missing?