怎么说呢,这三个注解是我在看SpringBoot源码的时候看到的,因为没有看过spring源码,也不清楚有没有,姑且先暂时算在spring学习里,等把spring吃透了再回来看
先来看一个一个常用注解@Controller
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface Controller {
/**
* The value may indicate a suggestion for a logical component name,
* to be turned into a Spring bean in case of an autodetected component.
* @return the suggested component name, if any
*/
String value() default "";
}
@interface 定义注解的时候,上面有四个注解, @Component就不说了,我们看一下剩下三个注解
正片开始:
1. @Target({ElementType.TYPE}) 注解
ElementType 这个枚举类型的常量提供了一个简单的分类:注释可