话不多说上图:
1 首先创建一个自定义的注解:
package com.jeecg.yfproject.dao;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.FIELD})//可以定义在方法上
@Retention(RetentionPolicy.RUNTIME)//运行有效,存在class字节码文件中
public @interface MyCFBAnnotation{
String value() default "";
}
2 绑定对应的字段
3 通过字段名(acceptTheTask)获得 “”接受课程“”
String field =“ ”;
类名.getClass().getDeclaredField("字段名")
// 获得字段注解
Field field = tYfProcessStudyEntity.getClass().getDeclaredField("acceptTheTask");// 暴力获取private修饰的成员变量
MyCFBAnnotation myFieldAnnotation =field.getAnnotation(MyCFBAnnotation.class);//MyFieldAnnotation是注解名
System.out.println(myFieldAnnotation.value());