Spring component-scan

Spring component-scan

<context:component-scan base-package="com.xyz">
	
		<context:include-filter type="regex"
			expression="com\.xyz\.rest\.dao\..*DaoImpl" />
</context:component-scan>



Element : component-scan
Scans the classpath for annotated components that will be auto-registered as Spring beans. By default, the
Spring-provided @Component, @Repository, @Service, and @Controller stereotypes will be detected. Note:
This tag implies the effects of the 'annotation-config' tag, activating @Required, @Autowired,
@PostConstruct, @PreDestroy, @Resource, @PersistenceContext and @PersistenceUnit annotations in the
component classes, which is usually desired for autodetected components (without external configuration).
Turn off the 'annotation-config' attribute to deactivate this default behavior, for example in order to use
custom BeanPostProcessor definitions for handling those annotations. Note: You may use placeholders in
package paths, but only resolved against system properties (analogous to resource paths). A component
scan results in new bean definition being registered; Spring's PropertyPlaceholderConfigurer will apply to
those bean definitions just like to regular bean definitions, but it won't apply to the component scan
settings themselves. See javadoc for org.springframework.context.annotation.ComponentScan for
information on code-based alternatives to bootstrapping component-scanning.

Content Model : (include-filter*, exclude-filter*)

猜你喜欢

转载自lizhuang.iteye.com/blog/2177694