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

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean to consumed

$
0
0

Getting this failure while running.

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

What needs to be changed?

@Configuration@EnableRedisRepositoriespublic class RedisConfig {    //establish a redis connection    @Bean    public JedisConnectionFactory connectionFactory(){        RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration();        configuration.setHostName("localhost");        configuration.setPort(6379);        return new JedisConnectionFactory(configuration);    }    //template to access redis-server form our application    @Bean    public RedisTemplate<String, Object> redisTemplate(){        RedisTemplate<String, Object> template = new RedisTemplate<>();        template.setConnectionFactory(connectionFactory());        template.setKeySerializer(new StringRedisSerializer());        template.setHashKeySerializer(new StringRedisSerializer());        template.setHashKeySerializer(new JdkSerializationRedisSerializer());        template.setValueSerializer(new JdkSerializationRedisSerializer());        template.setEnableTransactionSupport(true);        template.afterPropertiesSet();        return template;    }}
***************************APPLICATION FAILED TO START***************************Description:Field template in com.singashi.springdataredisdemo.dao.ProductDao required a single bean, but 2 were found:    - redisTemplate: defined by method 'redisTemplate' in class path resource [com/singashi/springdataredisdemo/config/RedisConfig.class]    - stringRedisTemplate: defined by method 'stringRedisTemplate' in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.class]Action:Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>