根据文档,为了激活板球破碎机,我必须在属性中添加feign.circuitbreaker.enabled=true。
它正在工作,但我想找到一种用注释激活的方法。
我试过
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-circuitbreaker-resilience4j</artifactId>
</dependency>和
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@EnableFeignClients
public @interface EnableFeign {
}和
@Configuration
@EnableFeign
public class FeignConfiguration {
public FeignConfiguration() {
Properties properties = System.getProperties();
properties.setProperty("feign.circuitbreaker.enabled", "true");
}
}但这是行不通的。属性似乎是在初始化EnableFeignClients之后设置的,并且我得到了一个异常
Cannot invoke "org.springframework.cloud.openfeign.CircuitBreakerNameResolver.resolveCircuitBreakerName(String, feign.Target, java.lang.reflect.Method)" because "this.circuitBreakerNameResolver" is null]在Intellij中的“热重新加载”之后,它就可以工作了,因为该属性仍然存在。
所以这就是方法。我也更喜欢只有一个注释,而不是构造函数在FeignConfiguration中
有办法这样做并让它起作用吗?
发布于 2022-09-13 04:00:21
你是怎么制造假象的?
Feign.builder()还是FeignCircuitBreaker.builder()?
使用'FeignCircuitBreaker.builder()‘将得到异常。
https://stackoverflow.com/questions/72485615
复制相似问题