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提示对错误的说明还是很清楚的了,仔细看看总能找到答案。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM