博主
258
258
258
258
专辑

第八节 使用HuTool工具中的注解工具

亮子 2023-11-25 14:48:43 6338 0 0 0
    @ApiOperation("AnnotationUtil使用:注解工具类")
    @GetMapping("/annotationUtil")
    public CommonResult annotationUtil(){
        //获取指定类、方法、字段、构造器上的注解列表
        Annotation[] annotations = AnnotationUtil.getAnnotations(HutoolController.class, false);
        LOGGER.info("annotationUtil annotations:{} ",annotations[1]);
        //获取指定类型的注解
        Api api = AnnotationUtil.getAnnotation(HutoolController.class, Api.class);
        LOGGER.info("annotationUtil api value:{}",api.description());
        //获取指定类型注解的值
        Object annotationValue = AnnotationUtil.getAnnotationValue(HutoolController.class, RequestMapping.class);
        LOGGER.info("annotationUtil annotationValue:{} ",annotationValue);
        return CommonResult.success(null,"操作成功!");
    }