spring::注解开发@ComponentScan

@ComponentScan

@ComponentScan将@Controller @Service @Repository,@Component标识的类注入到spring容器

@Bean
与上面的不同的是,上面作用域是类,而@Bean是作用方法

这些相当于是
<bean id="" class="">

@ComponentScan
相当于是xml文件

在Springboot中有个@SpringBootApplication注解里面有@ComponetScan扫描的是@SpringBootApplication类路径同级或者包下的注解

posted @ 2022-12-09 10:17  壹剑霜寒十四州  阅读(12)  评论(0编辑  收藏  举报