spring关于bean的一些配置说明
2024-10-07 21:17:13
<context:annotation-config> 是用于激活那些已经在spring容器里注册过的bean上面的注解。该标签主要向容器中掩式定的注了 AutowiredAnnotationBeanPostProcessor CommondAnnotationBeanPostProcessor PersistenceAnnotationBeanPostProcessor RequiredAnnotationBeanPostProcessor这四大组件
AutowiredAnnotationBeanPostProcessor:主要是使用@AutoWired注解时,必须提前向Spring容器注册这个BeanPostprocessor
传统的配置方式:<bean class="org.springframework.beans.factory.annotation. AutowiredAnnotationBeanPostProcessor "/>
传统的配置方式:<bean class="org.springframework.beans.factory.annotation. AutowiredAnnotationBeanPostProcessor "/>
CommondAnnotationBeanPostprocessor:主要是使用@Resource、@PostConstruct、@Predestory等注解时,必须提前向Spring容器注册。
传统配置方式:<bean class="org.springframework.beans.factory.annotation.CommondAnnotationBeanPostprocessor"/>
传统配置方式:<bean class="org.springframework.beans.factory.annotation.CommondAnnotationBeanPostprocessor"/>
PersistenceAnnotationBeanPostProcessor :主要是使用@PersistenceContext注解时,必须提前向Spring容器注册。
传统配置方式:<bean class="org.springframework.beans.factory.annotation.PersistenceAnnotationBeanPostProcessor"/>
传统配置方式:<bean class="org.springframework.beans.factory.annotation.PersistenceAnnotationBeanPostProcessor"/>
RequiredAnnotationBeanPostProcessor:主要是使用@Required注解时,必须提前向Spring容器注册。
传统配置方式:<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>
传统配置方式:<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>
<context:component-scan>除了具有<context:annotation-config>的功能之外,<context:component-scan>还可以在指定的package下扫描以及注册javabean 。该标签只是向spring容器中注册 AutowiredAnnotationBeanPostProcessor 实例, 该实例可以自动装配具有 @Autowired 和@Resource 、@Inject注解的属性.
@Service用于标注业务层组件,@Controller用于标注控制层组件(如struts中的action),@Repository用于标注数据访问组件,即DAO组件,而@Component泛指组件,当组件不好归类的时候,我们可以使用这个注解进行标注。
@Autowired与@Resource都可以用来装配bean。
最新文章
- long和BigDecimal引发的管理思考
- LCA倍增算法的错误与模板
- jQueryMobile控件之展开与合并
- windows下python检查文件是否被其它文件打开.md
- nginx 重写 rewrite 基础及实例
- 选择Web API还是WCF
- HDU 4099 Revenge of Fibonacci(高精度+字典树)
- linux系统编程:进程间通信-mmap
- [转] React同构思想
- runAllManagedModulesForAllRequests 和 invalid url
- Sudoku(回溯)
- Java并发编程之闭锁CountDownLatch简单介绍
- [ An Ac a Day ^_^ ] CodeForces 680A Bear and Five Cards
- 用js来实现那些数据结构(栈01)
- 部署testlink报错,安装wampserver时提示丢失MSVCR110.dll
- css布局-双飞翼布局
- 自定义域名访问本地WEB应用
- Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-C. Plasticine zebra
- python 全栈开发,Day113(方法和函数的区别,yield,反射)
- URL的井号