spring boot 整合redis 报错(在redis中存储数据报错)

spring boot 整合redis 报错(在redis中存储数据报错)

在这里插入图片描述

2023-06-30 16:03:00.067  WARN 34296 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rdiMesController': Unsatisfied dependency expressed through field 'rdiMesService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rdiMesServiceImpl': Unsatisfied dependency expressed through field 'soRedisTemplate'; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.data.redis.core.RedisTemplate<?, ?>' available: expected single matching bean but found 2: redisTemplate,stringRedisTemplate
2023-06-30 16:03:00.067  INFO 34296 --- [           main] c.b.d.d.DynamicRoutingDataSource         : dynamic-datasource start closing ....
2023-06-30 16:03:00.067  INFO 34296 --- [           main] c.b.d.d.DynamicRoutingDataSource         : dynamic-datasource all closed success,bye
2023-06-30 16:03:00.069  INFO 34296 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2023-06-30 16:03:00.087  INFO 34296 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-06-30 16:03:00.103 ERROR 34296 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
Description:

Field soRedisTemplate in com.ruoyi.rdimes.service.impl.RdiMesServiceImpl required a single bean, but 2 were found:
	- redisTemplate: defined by method 'redisTemplate' in class path resource [com/ruoyi/common/redis/configure/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

2023-06-30 16:03:00.104  WARN 34296 --- [       Thread-1] c.a.n.common.http.HttpClientBeanHolder   : [HttpClientBeanHolder] Start destroying common HttpClient
2023-06-30 16:03:00.105  WARN 34296 --- [       Thread-5] c.a.nacos.common.notify.NotifyCenter     : [NotifyCenter] Start destroying Publisher
2023-06-30 16:03:00.105  WARN 34296 --- [       Thread-5] c.a.nacos.common.notify.NotifyCenter     : [NotifyCenter] Destruction of the end

Process finished with exit code 1
***************************
APPLICATION FAILED TO START
***************************

解决办法增加注解Qualifier

原注解代码

    @Autowired
    private RedisTemplate soRedisTemplate;//支持redis五大类型中的所有类型

改后注解代码

    @Autowired
    @Qualifier("redisTemplate")
    private RedisTemplate soRedisTemplate;//支持redis五大类型中的所有类型

成功存储数据并且取到
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值