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

Failed to instantiate RedisTemplate in Spring Boot

$
0
0

I have a Spring Boot Application with Java 17 and Spring Boot 3.1.0, I am trying to connect my application with redis server but when I try to run the application it throws an exception as

aused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'redisService': Unsatisfied dependency expressed through field 'redisTemplate': Failed to instantiate [org.springframework.data.redis.core.RedisTemplate]: Factory method 'redisTemplate' threw exception with message: org.springframework.data.convert.EntityInstantiators

My Config class is as

@Configurationpublic class RedisConfig {    @Value("${spring.data.redis.host}")    private String redisHost;    @Value("${spring.data.redis.port}")    private int redisPort;    @Bean    public LettuceConnectionFactory redisConnectionFactory() {        RedisStandaloneConfiguration redisConfig = new RedisStandaloneConfiguration(redisHost, redisPort);        return new LettuceConnectionFactory(redisConfig);    }    @Bean    public RedisTemplate<String, Object> redisTemplate() {        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();        redisTemplate.setConnectionFactory(redisConnectionFactory());        redisTemplate.setKeySerializer(new StringRedisSerializer());        redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());        return redisTemplate;    }}

Can anyone help me with this? Did I miss anything?Thank you!


Viewing all articles
Browse latest Browse all 2204

Trending Articles