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

错误信息

在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版本信息:



	org.springframework.cloud
	spring-cloud-dependencies
	Hoxton.SR12
	pom
	import



	com.alibaba.cloud
	spring-cloud-alibaba-dependencies
	2.2.1.RELEASE
	pom
	import

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

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

开启Sentinel对Feign的支持:

feign:
  sentinel:
    enabled: true

Service类:

@FeignClient(value = "nacos-payment-provider",fallback = TestFallbackService.class)
public interface TestService {
    @GetMapping(value = "/paymentSQL/{id}")
    public CommonResult paymentSQL(@PathVariable("id") Long id);
}

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

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



	org.springframework.cloud
	spring-cloud-dependencies
	Hoxton.SR3
	pom
	import



	com.alibaba.cloud
	spring-cloud-alibaba-dependencies
	2.2.1.RELEASE
	pom
	import


 

你可能感兴趣的:(sentinel,spring,cloud,spring,boot)