SpringBoot核心注解

1.@SpringBootApplication

这个注解是@SpringBootConfiguration、@EnableAutoConfiguration、@ComponentScan这三个注解的组合。

2.@EnableAutoConfiguration

允许SpringBoot自动配置注解,开启这个注解后,SpringBoot就能根据当前类路径下的包或者类来配置SpringBean。

3.@Configuration

这是Spring3.0添加的一个注解,用来代替applicationContext.xml配置文件,所有这个配置文件里面能做到的事情都可以通过这个注解所在类来进行注册。

4.@SpringBootConfiguration

这个注解就是@Configuration注解的变体,只是用来修饰是SpringBoot配置而已,或者可利于SpringBoot后续的扩展。

5.@ComponentScan

这是Spring3.1添加的一个注解,用来代替配置文件中的component-scan配置,开启组件扫描,即自动扫描包路径下的@Component注解进行注册bean实例到context中。