【问题标题】:Creating default custom Hystrix Property创建默认自定义 Hystrix 属性
【发布时间】:2018-08-01 09:09:12
【问题描述】:
我是 Hystrix 的新手,我只是将它添加到我的项目中,但我想知道是否可以创建一个自定义注释“HystrixDefaultTimeoutProperty”来扩展 HystrixProperty,所以每次我想使用超时的默认值我可以使用该自定义注释而不是使用:
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "5000")
提前致谢!
【问题讨论】:
标签:
annotations
spring-cloud-netflix
hystrix
【解决方案1】:
不,不可能,如果你要查看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})
这意味着您只能在方法上使用这些注释