首页 > 解决方案 > 使用 java 注解创建局部变量

问题描述

@Slf4j 如何公开局部变量日志以供使用?查看源代码没有任何提示。

@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.TYPE})
public @interface Slf4j {
    String topic() default "";
}

标签: javaslf4jlombok

解决方案


// m() method wont compile at run time
// compile time no output it shown
// when run at directly n() method will produce as output 

class Sampleanote
 {
   void m()
    {
        System.out.println("sample annotation at complile");
     }

 @Deprecated
 void n()
    {
        System.out.println("run time annotation  ");
     }
 }

 class Annote
   {
       public static void main(String args[])
      {

         Sampleanote a=new Sampleanote();
         a.n();   //at run time it produce output
       }
    }

推荐阅读