diff --git a/src/main/java/com/annotation/ColumnInfo.java b/src/main/java/com/annotation/ColumnInfo.java index d041578..284a667 100644 --- a/src/main/java/com/annotation/ColumnInfo.java +++ b/src/main/java/com/annotation/ColumnInfo.java @@ -1,13 +1,26 @@ +// 定义该文件所在的包路径,将该 Java 类组织到 com.annotation 这个包空间下,方便项目的模块化管理和避免类名冲突 package com.annotation; +// 导入 Java 语言中用于表示注解可应用的目标元素类型的类,通过该类可以指定注解能作用于类、方法、字段等不同的程序元素 import java.lang.annotation.ElementType; + +// 导入用于指定注解保留策略的注解,借助它可以控制注解在不同阶段的可见性 import java.lang.annotation.Retention; + +// 导入定义注解保留策略的枚举类,其中包含了 SOURCE(仅在源码中保留)、CLASS(在编译后的字节码文件中保留,但运行时不可用)、RUNTIME(在运行时可用)等不同的保留策略常量 import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +// 导入用于指定自定义注解可以应用的目标元素类型的注解,和 ElementType 配合使用,明确注解具体能作用在哪些程序元素上 +import java.lang.annotation.Target; +// 指定该注解可以应用于字段(类的成员变量)上 @Target(ElementType.FIELD) +// 指定该注解在运行时保留,可以通过反射读取 @Retention(RetentionPolicy.RUNTIME) +// 定义一个名为ColumnInfo的注解 public @interface ColumnInfo { + // 定义comment属性,表示字段的注释/描述 String comment(); + + // 定义type属性,表示字段的类型 String type(); }