spring-cloud-alibaba icon indicating copy to clipboard operation
spring-cloud-alibaba copied to clipboard

重写sentinel 的feign builder 后服务启动时 feignSentinelBuilder 与 seata 的 feignSentinelBuilder 冲突

Open liyf155 opened this issue 4 years ago • 4 comments

微服务项目同时集成了 sentinel 版本 2021.1 seata 版本1.4.2 spring boot 版本 2.4.3 spring cloud版本 2020.0.1 为了避免写fallback和fallbackFacotry类,重写SentinelFeign.builder()类

@Configuration(proxyBeanMethods = false) @AutoConfigureBefore(SentinelFeignAutoConfiguration.class) public class XxxSentinelAutoConfiguration { @Bean @Scope("prototype") @ConditionalOnMissingBean public Feign.Builder feignSentinelBuilder() { return XxxSentinelFeign.builder(); } }

这样导致服务无法启动,错误如下:


APPLICATION FAILED TO START


Description:

The bean 'feignSentinelBuilder', defined in class path resource [com/alibaba/cloud/seata/feign/SeataFeignClientAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [cn/xxx/xxx/common/sentinel/XxxSentinelAutoConfiguration.class] and overriding is disabled.

Action:

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

不知道哪位大佬有没有遇到过类似的问题,尝试过一下解决方案:

  1. 将 feignSentinelBuilder 改个名字,这样会导致FeignClient注解的Bean不能加载
  2. 将 feign.sentinel.enable 设置为false,这样直接导致 seata 全局事务失效

liyf155 avatar Nov 19 '21 08:11 liyf155

你这个问题解决了吗?我也碰到了类似的问题,正在寻求解决方案

Memode avatar Jan 19 '22 06:01 Memode

同问

jackgege90 avatar Apr 15 '22 03:04 jackgege90

要不试试@AutoConfigureBefore({FeignAutoConfiguration.class, SentinelFeignAutoConfiguration.class})?

Bughue avatar Sep 05 '22 07:09 Bughue

This issue has been open 30 days with no activity. This will be closed in 7 days.

github-actions[bot] avatar Feb 02 '24 18:02 github-actions[bot]

This issue has been automatically marked as stale because it hasn't had any recent activity.If you think this should still be open, or the problem still persists, just pop a reply in the comments and one of the maintainers will (try!) to follow up. Thank you for your interest and contribution to the Sping Cloud Alibaba Community.

github-actions[bot] avatar Feb 27 '24 18:02 github-actions[bot]