spring <context:annotation-config /> 配置作用
来源:互联网 发布:数据仓库 数据加工 编辑:程序博客网 时间:2024/06/12 14:02
spring <context:annotation-config />
配置作用
1、从字面意思来理解就是 “注解配置” ,使用<context:annotation-config/>
元素可以自动声明“2”中的注解
2、替代了原来繁琐的配置,繁琐的配置如下:
配置<bean class="org.springframework.beans.factory.annotation. AutowiredAnnotationBeanPostProcessor "/>
才能使用@Autowired注解
配置<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor"/>
才能使用@Resource 、@PostConstruct、@PreDestroy注解
配置<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
才能使用@PersistenceContext注解
配置<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>
才能使用@Required注解
3、但由于 <context:component-scan base-package=”com.package”/>
也包含了自动注入“2”中bean的功能,所以<context:annotation-config/>
可以省略;同时存在的时候,前者会被忽略。 <context:component-scan>除了具有<context:annotation-config>的功能之外,<context:component-scan>还可以在指定的package下扫描以及注册javabean 。
详细请参考context:component-scan
- 配置Spring <context:annotation-config/>的作用
- spring <context:annotation-config /> 配置作用
- Spring 配置中<context:annotation-config/> 的作用
- Spring中的context:annotation-config作用
- Spring中<context:annotation-config/>的作用
- Spring <context:annotation-config/> 作用讲解
- Spring中<context:annotation-config/>的作用
- Spring中<context:annotation-config/>的作用
- Spring中<context:annotation-config/>的作用
- Spring中<context:annotation-config/>的作用
- Spring中<context:annotation-config/>的作用
- 关于Spring中的<context:annotation-config/>配置
- Spring配置中的<context:annotation-config/>
- Spring配置中的<context:annotation-config/>
- 关于Spring中的<context:annotation-config/>配置
- Spring中的<context:annotation-config/>配置
- 关于Spring中的<context:annotation-config/>配置
- 关于Spring中的<context:annotation-config/>配置
- spark python 环境搭建 windows10
- php之tp框架发邮件
- 试题一所有类
- Ubuntu安装JDK步骤
- struts 2批量上传文件技术总结,为自己的开发生涯多做一点贡献。
- spring <context:annotation-config /> 配置作用
- java设计模式
- QT接收SendMessage/PostMessage发出的消息
- Hbuilder中配置cmd
- 十六进制转字符串
- 1-自己实现string类(赋值运算符函数)
- 使用Excel中的插入对象功能在Excel中插入Word文档
- WCF分布式4:客户端访问寄宿在IIS中的WCF服务
- 无缝切换轮播图