Failed to parse configuration class xxx; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'feginClientConfig' for .....


  最近接到任务,重构公司的支付中心。目前公司有两套基础架构(在框架上在做封装),一套比较老,一套比较新。

既然是重构自然而然选择了新的一套。

  虽然是重构,但是其他的订单业务还是老的一套,多多少少还是需要和他们对接。

  在引用其他老项目的FeignClient。idea 一直提示Could not autowire. No beans of 'xxxx' type found。

  

  因为只是提示我也就没理会,启动项目的时候报错了:

  org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class xxx; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'feginClientConfig' for bean class xxxx conflicts with existing, non-compatible bean definition of same name and class xxxx。

  项目启动不了,就没办法往下走,于是就慢慢排查。

  最后发现是因为老项目的FeignClient是在org.springframework.cloud.netflix.feign.FeignClient 下

  而我用的新的FeignClient却是在org.springframework.cloud.openfeign.FeignClient 下。

  原来Spring Cloud对Feign的支持由org.springframework.cloud:spring-cloud-netflix-core移到org.springframework.cloud:spring-cloud-openfeign-core下了,所以导致扫描包一直扫描不到,所以idea 提示Could not autowire. No beans of 'xxxx' type found。

  解决办法:

  可以不依赖其他项目的Client。在自己项目把其他项目Client重新写一个,然后@FeignClient注解引org.springframework.cloud.openfeign.FeignClient包下的,接完美解决了。

  


免责声明!

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



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