一个注解要完整的使用需要三步:
1.定义这个注解本身:
package com.zyh.test.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(value={
ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME) //RUNTIME:运行时读取
public @interface ZyhTable{
// ZyhTable 用来修饰ZyhStudent,用来表示类跟表之间的转化。
String value();
}
2.在类里使用这个注解:
package com.zyh.test.annotation