Get an entity class field in java and then get one of its annotations, and then how to get the properties set in the annotations on this field?

for example, demo2 comment:

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
public @interface Demo2 {
    int max() default 100;

    int min() default 1;

    boolean isNotNull() default true;
}

now only the annotated attribute isNotNull is set in a field of the entity class

@Demo2(isNotNull = false)
    private String sex;

so how do I get this property set in the annotation on this field? That is, as long as the property with the new value is set, the other properties that do not set the new value do not get it?

Jun.25,2021

Field f = YourClass.class.getDeclaredField("sex");
Demo2 d = f.getDeclaredAnnotation(Demo2.class);
System.out.println(d.isNotNull());

   

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b375cd-40615.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b375cd-40615.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?