目录
1. bug描述
The bean 'redisTemplate', defined in class path resource [com/kone/sp/common/redis2/config/RedisTemplateAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.class] and overriding is disabled.

问题出现在我自定义 reids-starter 的时候
2. 出现的原因
错误的原因是, springboot 在启动时会优先加载 springboot 框架自带的 spring.factories 文件中的定义的自动配置类, 把框架原本的 redisTemplate 作为 bean 注入到 容器中, 之后才会加载我们自定义的 RedisTemplateAutoConfiguration, 并且再次把我们魔改过 redisTemplate 注入到 bean 中, 这样容器中出现了2个名字一样的 redisTemplate, 所以会出现

最低0.47元/天 解锁文章
2870

被折叠的 条评论
为什么被折叠?



