Hystrix后备方法不运行

Tia*_*sta 3 java circuit-breaker hystrix spring-cloud-netflix

我对一个关闭的端点运行调用,但是hystrix没有执行回退方法,并抛出异常:

java.util.concurrent.ExecutionException: org.springframework.web.client.ResourceAccessException: 
I/O error on GET request for "http://localhost:8080/wallet/customers/100/cards/": Conexão recusada (Connection refused); nested exception is java.net.ConnectException: Conexão recusada (Connection refused)
Run Code Online (Sandbox Code Playgroud)

有人知道是否缺少任何配置?

我的主要

@EnableCircuitBreaker
@SpringBootApplication
public class WalletPaymentApplication {

    public static void main(String[] args) {
        SpringApplication.run(WalletPaymentApplication.class, args);
    }
}
Run Code Online (Sandbox Code Playgroud)

和我的服务:

public PaymentMethodsData setUpPaymentMethods(String customerId) {
    return new PaymentMethodsData(getCardList(customerId));
}

@HystrixCommand(fallbackMethod = "getCardListCircuitBreaker")
public List<SummaryCardData> getCardList(String customerId) {
    return template.getForObject(configureUrl(cardUrl), CardRows.class, customerId).getRows();
}

public List<SummaryCardData> getCardListCircuitBreaker(String customerId){
    return new ArrayList<>();
}
Run Code Online (Sandbox Code Playgroud)

Bye*_*Bye 7

要使@HystrixCommand(fallbackMethod = "getCardListCircuitBreaker")您必须从另一个bean调用您的方法.然后注释将正常工作.