新建springboot项目后,项目自动生成一个Application 类 ,今天我们主要讲下SpringBootApplication注解
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class BootApplication {
public static void main(String[] args) {
SpringApplication.run(BootApplication.class, args);
}
}
点进去查看源码看到上面有好多个注解
@Target :
Indicates the contexts in which an annotation type is applicable。指示所适用的注解类型。这里ElementType.TYPE指的是适用于类。
@Retention:
Indicates how long annotations with the annotated type are to be retained. 指示注解类型的注解要保留多久。这里的保留策略是RUN