springboot集成redis 报错@Bean definition illegally overridden by existing bean definition@bean定义被现有bean定义非法重写

在做springboot集成redis时报如下错误:

org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'cacheManager' defined in class path resource [org/springframework/boot/autoconfigure/cache/RedisCacheConfiguration.class]: @Bean definition illegally overridden by existing bean definition: Generic bean: class [com.muyuer.bee.engine.cache.memory.MemoryCacheManager]; scope=; abstract=false; lazyInit=true; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [applicationContext-bee.xml]

百度居然没有相关文章,google也没有.
没办法只能仔细查看错误信息,关注到@Bean definition illegally overridden by existing bean definition,意思是@bean定义被现有bean定义非法重写,查看org/springframework/boot/autoconfigure/cache/RedisCacheConfiguration.class源码里面有一个@bean 名称为cacheManager,再看自己代码里也有一个同样名称的接口定义,报着试一下,把自己代码里的CacheManager接口改了一个名字,再运行居然成功了。

其实idea提示对错误的说明还是很清楚的了,仔细看看总能找到答案。

posted @ 2020-03-24 10:10  muyuer  阅读(1387)  评论(0编辑  收藏  举报