对注解使用默认配置

uz75evzq  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(191)

鉴于:

@Retryable(maxAttempts="{$some_var}", value=Exception.class, 
    backoff=@Backoff(maxDelay = "{$some_var}", random = "{$some_var}"))
public String foo() throws Exception {
  ...
}

@Retryable(maxAttempts="{$some_var}", value=Exception.class, 
    backoff=@Backoff(maxDelay = "{$some_var}", random = "{$some_var}"))
public String bar() throws Exception {
  ...
}

有没有一种方法可以将注解参数放入配置中,这样您就可以执行以下操作:

@Retryable(myDefaultRetryParams)
public String foo() throws Exception {
  ...
}

@Retryable(myDefaultRetryParams)
public String bar() throws Exception {
  ...
}

请注意,我正在寻找上述格式,而不是这样命名每个变量:

@Retryable(maxAttempts="{$some_var}", value=Exception.class, 
    backoff=@Backoff(maxDelay = "{$some_var}", random = "{$some_var}"))

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题