使用注释进行方法调用

时间:2017-11-23 09:40:33

标签: java annotations

我可以在方法调用上使用注释吗? @Target(ElementType.FIELD)@Target(ElementType.LOCAL_VARIABLE)似乎不起作用,IntelliJ抛出" 此处不允许使用注释"。 有没有办法使用这样的注释:

 class Test{ 
    void testA(){}  //Method declaration here

   public static void main(String[] args) { 
    @MyAnnotation 
    testA(); //annotation used at method invocation
  } 
}

我能否在不使用像Spring这样的框架的情况下做到这一点?仅适用于JavaSE或JavaEE。

0 个答案:

没有答案