Java 当用HystrixCommand注释的方法调用另一个引发异常的方法时,断路器不工作
我有一个抽象类Java 当用HystrixCommand注释的方法调用另一个引发异常的方法时,断路器不工作,java,spring-boot,spring-cloud-netflix,hystrix,Java,Spring Boot,Spring Cloud Netflix,Hystrix,我有一个抽象类 public abstract class A { public String makeSomething(String ingredients){ throw new RuntimeException("Can't Make anything"); } } 这个类在另一个类B(Spring服务)中实现,它通过传递成分在自己的许多方法中使用makeSomething。类B中的每个方法都使用HystrixCommand进行注释,并为其定义了回退。这
public abstract class A {
public String makeSomething(String ingredients){
throw new RuntimeException("Can't Make anything");
}
}
这个类在另一个类B(Spring服务)中实现,它通过传递成分在自己的许多方法中使用makeSomething。类B中的每个方法都使用HystrixCommand进行注释,并为其定义了回退。这是它的样子
@Service
public class B extends A {
@HystrixCommand(fallbackMethod = "doNothing")
public void makeTea(String ingredients){
makeSomething(ingredients);
}
public void doNothing(String ingredients){
System.out.println("Doing Nothing");
}
}
现在,当调用类B中的makeTea时,它会从类A中调用makeSomething,然后抛出异常。应将其包装为HystrixRuntimeException,然后调用fallback。但是我看到RunTimeException(“无法生成任何东西”)。根据您的描述,我想说,Hystrix没有启用 将
@enablehistrix
注释添加到应用程序类中,以便启用注释处理
如果已启用,请提供一个更完整的示例,在该示例中可以重现错误。谢谢您的回答@EnableHystrix已经存在。问题是别的。我在Github上与Netflix Hystrix有任何问题。@SuhelKhan您对此也有任何解决方案吗?您能否在此共享指向Github问题的链接。谢谢