@SpringBootApplication注解解析

@SpringBootApplication注解主要用于启动spring项目作为入口注解,其整合了

@EnableAutoConfiguration

@ComponentScan

两个主要的注解

 我们通过查看@SpringBootApplication注解源码可以看到

 @EnableAutoConfiguration、@ComponentScan介绍:

@EnableAutoConfiguration:能够自动配置spring的上下文,试图猜测和配置你想要的bean类,通常会自动根据你的类路径和你的bean定义自动配置。

@ComponentScan:会自动扫描指定包下的全部标有@Component的类,并注册成bean,当然包括@Component下的子注解@Service,@Repository,@Controller。

发布了106 篇原创文章 · 获赞 47 · 访问量 13万+

猜你喜欢

转载自blog.csdn.net/qq493820798/article/details/101063062
今日推荐