首页 > 移动平台 > 详细

Spring的applicationContext.xml的疑问解析

时间:2019-04-02 17:45:09      阅读:111      评论:0      收藏:0      [点我收藏+]

Spring中注解注入 context:component-scan 的使用说明

通常情况下我们在创建spring项目的时候在xml配置文件中都会配置这个标签,配置完这个标签后,spring就会去自动扫描base-package对应的路径或者该路径的子包下面的java文件,如果扫描到文件中带有@Service,@Component,@Repository,@Controller等这些注解的类,则把这些类注册为bean
注:在注解后加上例如@Component(value=”abc”)时,注册的这个类的bean的id就是adc.

Spring中context:annotation-config注解的作用

<context:annotation-config/>的作用是向Spring容器注册以下四个BeanPostProcessor:


AutowiredAnnotationBeanPostProcessor
CommonAnnotationBeanPostProcessor
PersistenceAnnotationBeanPostProcessor
RequiredAnnotationBeanPostProcessor

例如:
  如果想使用@Autowired注解,那么就必须事先在 Spring 容器中声明 AutowiredAnnotationBeanPostProcessor Bean。

Spring的applicationContext.xml的疑问解析

原文:https://www.cnblogs.com/w123w/p/10643821.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!