@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数据即不包含该属性。

原文地址:https://www.cnblogs.com/lqtbk/p/9816285.html