如何在Java中访问用户定义的注释的参数

时间:2019-04-01 10:17:02

标签: java annotations jersey java-annotations

I have my Custom Annotation  MyAnnotation.
I wanted to access the parameter passed to MyAnnotation.

MyAnnotation.java

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {

public String value() default 0;

}

myClient.java

public class myClient{

@MyAnnotation(value=10) 
public int someMethod(int addition){

//Wanted to Access the Value Of Value here which is 10

}

}

我们如何在someMethod()中访问Value的值。

0 个答案:

没有答案