I was trying to configure LettuceConnectionFactory in spring boot project with 1.5.15.RELEASE version.
This is my configuration file:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
@SpringBootApplication
public class RedisApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(RedisApplication.class);
@Bean
public LettuceConnectionFactory lettuceConnectionFactory()
{
LOGGER.info("Setup lettuce config");
final LettuceConnectionFactory factory = new LettuceConnectionFactory();
return factory;
}
@Bean
RedisTemplate<String,User> redisTemplate()
{
RedisTemplate<String,User> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(lettuceConnectionFactory());
return redisTemplate;
}
public static void main(String[] args) {
SpringApplication.run(RedisApplication.class, args);
}
}
I added the lettuce dependency in pom.xml
<dependency>
<groupId>biz.paluch.redis</groupId>
<artifactId>lettuce</artifactId>
<version>3.5.0.Final</version>
</dependency>
while starting project it was throwing error
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lettuceConnectionFactory' defined in com.example.redis.RedisApplication: Post-processing of merged bean definition failed; nested exception is java.lang.NoClassDefFoundError: com/lambdaworks/redis/api/StatefulRedisConnection