• @interface注解类、 @Target:注解的作用目标 @Retention @Configuration @Bean @JsonIgnore


    @interface 不是interface,是注解类 
    是jdk1.5之后加入的,java没有给它新的关键字,所以就用@interface 这么个东西表示了
    这个注解类,就是定义一个可用的注解,包括这个注解用于什么地方,是类,还是方法,还是property,还是方法入参等等

    @Retention(RetentionPolicy.RUNTIME)  // 注解会在class字节码文件中存在,在运行时可以通过反射获取到
    @Target:注解的作用目标
            @Target(ElementType.TYPE)   //接口、类、枚举、注解
            @Target(ElementType.FIELD) //字段、枚举的常量
            @Target(ElementType.METHOD) //方法
            @Target(ElementType.PARAMETER) //方法参数
            @Target(ElementType.CONSTRUCTOR)  //构造函数
            @Target(ElementType.LOCAL_VARIABLE)//局部变量
            @Target(ElementType.ANNOTATION_TYPE)//注解
            @Target(ElementType.PACKAGE) ///包   
    @Configuration(配置)
    /*
    *定义两个子类
    */
    package com.edu.fruit;
         @Configuration
         public class Apple implements Fruit<Integer>{//将Apple类约束为Integer类型
     
    }
     
    package com.edu.fruit;
         @Configuration
         public class GinSeng implements Fruit<String>{//将GinSeng 类约束为String类型
     
    }
     
    1.@Bean明确地指示了一种方法,
    2.什么方法呢——产生一个bean的方法,并且交给Spring容器管理;
    3.很明确地告诉被注释的方法,你给我产生一个Bean,然后交给Spring容器
    4.@Bean明确地指示了一种方法,什么方法呢——产生一个bean的方法,并且交给Spring容器管理
    注:@Bean就放在方法上,就是产生一个Bean
     
     

    注解@JsonIgnore的使用方法及其效果

      1、作用:在json序列化时将java bean中的一些属性忽略掉,序列化和反序列化都受影响。

      2、使用方法:一般标记在属性或者方法上,返回的json数据即不包含该属性。

  • 相关阅读:
    阻止a链接跳转的点击事件
    appium python版api
    Appium—python_ 安卓手机划屏幕操作
    appium-unittest框架中的断言
    Appium 服务关键字
    python mysql入库的时候字符转义
    python实现两个字典合并
    解决linux登录后总是时间过会就断开(解决ssh登录后闲置时间过长而断开连接)
    linux安装好redis,如何在window端访问?
    linux上安装redis
  • 原文地址:https://www.cnblogs.com/lqtbk/p/9816285.html
Copyright © 2020-2023  润新知