Java 我可以在单独的类中创建Hystrix全局回退函数吗?

Java 我可以在单独的类中创建Hystrix全局回退函数吗?,java,spring,hystrix,Java,Spring,Hystrix,假设我有以下控制器: import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties; import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty; import lombok.extern.s

假设我有以下控制器:

import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
@DefaultProperties(defaultFallback = "globalHandler.payment_Global_FallbackMethod")
public class OrderHystirxController
{
    @GetMapping("/consumer/payment/hystrix/timeout/{id}")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name="execution.isolation.thread.timeoutInMilliseconds",value="1500")
    })
    public String paymentInfo_TimeOut(@PathVariable("id") Integer id)
    {
        return "aaa";
    }
}
这里是代码

@DefaultProperties(defaultFallback = "globalHandler.payment_Global_FallbackMethod")
我的意思是,用payment\u Global\u FallbackMethod函数创建一个GlobalHandler类组件,尝试让其他控制器共享使用它。可能吗

import org.springframework.stereotype.Component;

@Component
public class GlobalHandler
{
    public String payment_Global_FallbackMethod()
    {
        return "[GlobalHandler][payment_Global_FallbackMethod], Global level fallback";
    }
}