如何动态地将参数值传递给自定义注释



我正在使用一个库,它创建了以下自定义注释。

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@DependsOn({"springBeanUtils"})
public @interface PartyCacheable {
boolean enable() default false;
}

下面是我使用上述注释

的代码片段
@PartyCacheable(enable = false)       // this value needs to be toggled from property value 
public class PartyProcessing {
// some implementation
}

是否有一种方法可以根据应用程序将PartyCacheable注释与true和false切换。属性文件?

party.cache.enable=true

不可以在属性中使用注释。注释必须与常量一起使用。

最新更新