java - 使用 java 注解创建局部变量
问题描述
@Slf4j 如何公开局部变量日志以供使用?查看源代码没有任何提示。
@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.TYPE})
public @interface Slf4j {
String topic() default "";
}
解决方案
// 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
}
}
推荐阅读
- azure - 尝试使用 $expand(microsoft.graph.itemattachment/item) 读取 ItemAttachment 属性时,Microsoft Graph API“访问被拒绝”
- typescript - React.memo 和打字稿
- r - 如何将 covid19.analytics 中的 live.map 功能添加到闪亮的应用程序中?
- java - Leetcode #11 装水最多的容器:为什么要使用“else”
- kubernetes - 我在 gitlab 中的自动 devops 管道不起作用
- php - 通过维基数据获取比利时的城市列表
- mysql - 当使用触发器更改另一个字段时,从表中更改字段的值
- python - 确定每组的连续日期期间
- excel - 将所有 pdf 文件移动到新文件夹
- laravel - 在 laravel 上使用 like 无法显示日期搜索