在springboot中,我们常见的@ComponentScan注解是什么?

 Spring注解 之 @ComponentScan注解

其实很简单,@ComponentScan主要就是定义扫描的路径从中找出标识了需要装配的类自动装配到spring的bean容器中

相当于之前的 <context:component-scan>。

 

 

 Spring注解 之 @ComponentScan注解

 

 

Spring是一个依赖注入框架。所有的内容都是关于bean的定义及其依赖关系。

配置这个注解Spring就会去自动扫描对应的路径或者该路径的子包下面的java文件,如果扫描到文件中带有

@Service,@Component,@Repository,@Controller等这些注解的类,则把这些类注册为bean

Spring注解 之 @ComponentScan注解

 

相关文章:

  • 2022-03-05
  • 2021-05-15
  • 2021-07-27
  • 2021-08-08
  • 2022-12-23
  • 2022-12-23
  • 2023-01-10
  • 2022-01-23
猜你喜欢
  • 2022-12-23
  • 2022-02-03
  • 2022-01-09
  • 2022-12-23
  • 2021-12-06
  • 2021-12-02
相关资源
相似解决方案