2017-06-06 30 views
2

我运行一个调用的端点是关闭的,但是红椎不执行备用方法,并抛出一个异常:猬备用方法不运行

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) 

任何人都知道,如果任何配置丢失?

我的主要

@EnableCircuitBreaker 
@SpringBootApplication 
public class WalletPaymentApplication { 

    public static void main(String[] args) { 
     SpringApplication.run(WalletPaymentApplication.class, args); 
    } 
} 

,我的服务:

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<>(); 
} 
+1

啊,要启用注释,你必须从另一个bean调用你的方法。 – ByeBye

+0

:O,ty man,perfect –

回答

4

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

+0

ty,它的作品... –

+0

谢谢,请问你能提出背后的原因吗? – Cady

+0

不知道为什么它是这样的。有点奇怪。 –