创建默认自定义 Hystrix 属性

Creating default custom Hystrix Property

我是 Hystrix 的新手,我只是将它添加到我的项目中,但我想知道我是否可以创建一个扩展 HystrixProperty 的自定义注释 "HystrixDefaultTimeoutProperty",所以每次我想为超时使用默认值我可以使用该自定义注释而不是使用:

@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "5000")

提前致谢!

不,这是不可能的,如果你要查看 HystrixCommand@HystrixProperty

的源代码
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface HystrixCommand {
  .....
}

@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface HystrixProperty {
  .....
}

这两个注释都有

@Target({ElementType.METHOD})

这意味着您只能在方法上使用这些注释