0


SpringBoot的25个核心注解(专题五)

1、@SpringBootApplication

翻译:SpringBoot应用

这是SpringBoot最核心的注解,用在SpringBoot的主类上,标识这是一个SpringBoot的应用,用来开启SpringBoot的各种能力(通过配置@SpringBootApplication的主类启动后,会自动扫描并加载该主类所对应包下的bean,并交由Spring进行管理)

@SpringBoot是@SpringBootConfiguration(SpringBoot配置)@EnableAutoConfiguration(启动自动配置)@ComponentScan(组件扫描)这三个注解的组合。

2、@EnableAutoConfiguration

翻译:启动自动配置

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

3、@Configuration

翻译:配置

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

4、@SpringBootConfiguration

翻译:SpringBoot的配置类

SpringBoot用来修饰@Configuration的

5、@ComponentScan

翻译:组件扫描

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

网卡,待续

标签: spring boot

本文转载自: https://blog.csdn.net/Pleasure258/article/details/129327112
版权归原作者 Pleasure258 所有, 如有侵权,请联系我们删除。

“SpringBoot的25个核心注解(专题五)”的评论:

还没有评论