Spring注解全面介绍
Spring2.5 注解介绍(3.0通用)
Auther: 韩群峰 Version: 1.0.0 Date: 2011-03-15
注解说明
注册注解处理器
方式一:bean
<bean class="org.springframework.beans.factory.annotation.
AutowiredAnnotationBeanPostProcessor"/>
方式二: 命名空间<context:annotation-config />
<context:annotationconfig /> 将隐式地向Spring 容器注册
AutowiredAnnotationBeanPostProcessor、
CommonAnnotationBeanPostProcessor 、 PersistenceAnnotationBeanPostProcessor 以及RequiredAnnotationBeanPostProcessor 这4 个
BeanPostProcessor 。 方式三: 命名空间<context:component-scan />
如果要使注解工作,则必须配置component-scan ,实际上不需要再配置annotation-config。
base-package 属性指定了需要扫描的类包,类包及其递归子包中所有的类都会被处理。还允许定义过滤器将基包下的某些类纳入或排除。
Spring 支持以下4 种类型的过滤方式:
注解 org.example.SomeAnnotation 将所有使用SomeAnnotation 注解的类过滤出来
类名指定 org.example.SomeClass 过滤指定的类
正则表达式 com.kedacom.spring.annotation.web..* 通过正则表达式过滤一些类 AspectJ 表达式 org.example..*Service+ 通过AspectJ 表达式过滤一些类
正则表达式的过滤方式举例:
<context:component-scanbase-package="com.casheen.spring.annotation"> <context:exclude-filtertype="reg
ex"
expression="com.casheen.sprin
g.annotation.web..*"/>
</context:component-scan>
注解的过滤方式举例:
编写主类测试: @Service public class Main { 使用 Spring2.5 的 Autowired 实现注释型的 IOC @Autowired @Qualifier("chinese") private Man man; public ...
Spring注解全面介绍 11页 1下载券 spring注解详细介绍 15页 免费 spring注解...一、各种注解方式 1.@Autowired 注解(不推荐使用,建议使用@Resource) @Autowired...
spring注解详细介绍_计算机软件及应用_IT/计算机_专业资料。提高Spring 开发效率 拍拖xml的繁琐配置 充分利用spring注解 让你快人一步...
spring注解详细介绍-1特别好_计算机软件及应用_IT/计算机_专业资料。使用 Spring2.5 的 Autowired 实现注释型的 IOC 使用 Spring2.5 的 Autowired 实现注释型的...
java注解spring注解 详解_计算机软件及应用_IT/计算机_专业资料。对spring java中的注解用法进行详细介绍基本内置注解 @Override java 中覆写 @Deprecated 的作用是...
【分享】Spring2.5注解介绍 Auther: Version: Date: 韩群峰 1.0.0 2011-03-15 Contents Agenda 注解说明 注解说明 注解说明 注解说明 注解说明 注解说明 注解...
使用Spring2.5 的 Autowired 实现注释型的 IOC 使用 Spring2.5 的 Autowired 实现注释型的 IOC 使用 Spring2.5 的新特性——Autowired 可以实现快速的自动注入...
2. 使用 Spring 注解完成 Bean 的定义 以上我们介绍了通过@Autowired 或@Resource 来实现在 Bean 中自动注入的功能,下面我们 将介绍如何注解 Bean,从而从 XML ...
Spring注解_计算机软件及应用_IT/计算机_专业资料。Spring框架的注解介绍和用法。Spring-注解我们在使用 spring 依赖注入的时候,配置文件里面会配置大量<property>标签...
2. 使用 Spring 注解完成 Bean 的定义 以上我们介绍了通过@Autowired 或@Resource 来实现在 Bean 中自动注入的功能,下面 我们将介绍如何注解 Bean,从而从 XML ...
热门文档