反射获取所有属性名,判断属性上是否有此注解以及注解的值,


        Field[] fields = TableMainAddVO.class.getDeclaredFields();
        List<String> strList =  new ArrayList<String>();
        Arrays.stream(fields).forEach(f -> {
            if(f.isAnnotationPresent(ApiModelProperty.class)){
                ApiModelProperty annotation = f.getAnnotation(ApiModelProperty.class);
                String value = annotation.value();
                strList.add(value+":"+f.getName());
            }
        });

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM