gpt4 book ai didi

hystrix - Spring-Cloud Hystrix(未找到备用方法)

转载 作者:行者123 更新时间:2023-12-04 10:06:54 27 4
gpt4 key购买 nike

我正在尝试使用hyst,但是在调用save方法时,该方法使带有resttemplate的帖子出现以下异常:

com.netflix.hystrix.contrib.javanica.exception.FallbackDefinitionException:找不到后备方法:breaker([class com.wnb.mastercard.domain.enroll.EnrollCommand])

有人能帮我吗?

@Component
public class EnrollRepositoryRest {

@Autowired
private RestTemplate template;

@Value("${beblue-card-enroll.url}")
private String url;

public Enroll getEnrollByCardId(String cardId) {

Enroll[] enroll = template.getForObject(url + "cardEnroll/enroll/" + cardId, Enroll[].class);

return enroll[0];
}

@HystrixCommand(fallbackMethod = "breaker")
public void save(EnrollCommand command) {
template.postForObject(url + "/cardEnroll/enroll", command, EnrollCommand.class);
}

public String breaker() {
System.out.println("HYSTRIX EXECUTADO");
return "Hystrix is Ok";
}
}

最佳答案

我认为异常(exception)显然可以告诉您问题所在。方法:

public String breaker(EnrollCommand command) {
System.out.println("HYSTRIX EXECUTADO");
return "Hystrix is Ok";
}

不存在。 (注意签名中的参数)

当使用该批注定义后备方法时,后备方法必须与定义Hystrix命令的方法的参数相同。

关于hystrix - Spring-Cloud Hystrix(未找到备用方法),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41978208/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com