weixin_47056195 2021-07-08 11:39 采纳率: 88.9%
浏览 1875
已结题

项目启动时redis 注入bean报错 The bean 'stringRedisTemplate'

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-07-08 11:34:24.403 ERROR 11284 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:

The bean 'stringRedisTemplate', defined in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [com/byjz/ia/commons/redis/RedisConfig.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

Disconnected from the target VM, address: '127.0.0.1:62886', transport: 'socket'

Process finished with exit code 1

  • 写回答

3条回答 默认 最新

  • 得一以生 2021-07-08 11:49
    关注

    你自己定义的RedisConfig.class中定义了一个bean,name为stringRedisTemplate,导致spring的RedisAutoConfiguration.class中同名的bean,也叫RedisAutoConfiguration,无法注册,修改一下你自己定义的bean的name

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 11月17日
  • 已采纳回答 11月9日

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog