首页  

spring组件扫描     所属分类 spring 浏览量 1065
Spring2.5 引入组件自动扫描机制

扫描指定路径下指定注解的类
@Component @Service @Controller @Repository

context:include-filter
context:exclude-filter



<context:component-scan base-package="a.b" />

只扫描 controller 组件
<context:component-scan base-package="a.b">  
    <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>   
</context:component-scan>  




filter type    annotation,aspectj,assignable,custom,regex

regex 按照正则表达式
custom 自定义规则  实现org.springframework.core.type.TypeFliter接口
assignable	派生于指定类型的那些类



@PostConstruct @PreDestroy

组件自动注入  自动装配 
@Autowired @Resource @Inject


@ComponentScan(basePackages = {"a.b", "x.y"})

上一篇     下一篇
一条shell命令生成目录树结构

使用jar命令生成jar包

spring资源加载机制

spring实战之javaconfig

jar包冲突的处理套路

spring注解之@Value