ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Sentinel整合OpenFeign时出现循环依赖解决(Is there an unresolvable circular reference?)

2021-11-04 23:30:25  阅读:364  来源: 互联网

标签:unresolvable OpenFeign spring there alibaba Sentinel import cloud


错误信息

在OpenFeign整合Sentinel的时候出现循环依赖的报错

Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException:Error creating bean with name 'top.mowang.cloud.service.PaymentService': Requested bean is currently in creation: Is there an unresolvable circular reference?

环境信息

Spring Cloud和Spring Cloud Alibaba版本信息:

<!--spring cloud Hoxton.SR12-->
<dependency>
	<groupId>org.springframework.cloud</groupId>
	<artifactId>spring-cloud-dependencies</artifactId>
	<version>Hoxton.SR12</version>
	<type>pom</type>
	<scope>import</scope>
</dependency>
<!--spring cloud alibaba 2.1.0.RELEASE-->
<dependency>
	<groupId>com.alibaba.cloud</groupId>
	<artifactId>spring-cloud-alibaba-dependencies</artifactId>
	<version>2.2.1.RELEASE</version>
	<type>pom</type>
	<scope>import</scope>
</dependency>

我是在当前OpenFeign能成功整合Hystrix的前提下进行和Sentinel整合

在开启Sentinel对Feign的支持的配置后在启动时就出现了循环依赖的问题

开启Sentinel对Feign的支持:

feign:
  sentinel:
    enabled: true

PaymentService类:

@FeignClient(value = "nacos-payment-provider",fallback = PaymentFallbackService.class)
public interface PaymentService {
    @GetMapping(value = "/paymentSQL/{id}")
    public CommonResult<Payment> paymentSQL(@PathVariable("id") Long id);
}

PaymentService在注入到controller出现了循环依赖

问题原因和目前的解决方案

问题出在Spring Cloud和Spring Cloud Alibaba的版本上,具体就是Sentinel和OpenFeign版本兼容问题,目前的解决方案就是切换为兼容的版本,等待官方修复,在将spring cloud版本为Hoxton.SR3,spring cloud alibaba版本为2.1.0.RELEASE后正常启动,问题解决

<!--spring cloud Hoxton.SR3-->
<dependency>
	<groupId>org.springframework.cloud</groupId>
	<artifactId>spring-cloud-dependencies</artifactId>
	<version>Hoxton.SR3</version>
	<type>pom</type>
	<scope>import</scope>
</dependency>
<!--spring cloud alibaba 2.1.0.RELEASE-->
<dependency>
	<groupId>com.alibaba.cloud</groupId>
	<artifactId>spring-cloud-alibaba-dependencies</artifactId>
	<version>2.2.1.RELEASE</version>
	<type>pom</type>
	<scope>import</scope>
</dependency>

作者(Author):魔王Dany
链接(URL):https://mowangblog.top/mowang/sentinel
来源(Source):魔王の博客

标签:unresolvable,OpenFeign,spring,there,alibaba,Sentinel,import,cloud
来源: https://blog.csdn.net/weixin_43325510/article/details/121153962

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有