整了一下午,测通注解版的Spring 3.0配置,备忘一下。
<?xml version="1.0" encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:annotation-config/>
<context:component-scan base-package="test,abc"/>
</beans>
其中context:annotation-config自动加载4种注入处理器:AutowiredAnnotationBeanPostProcessor, CommonAnnotationBeanPostProcessor, PersistenceAnnotationBeanPostProcessor 和 RequiredAnnotationBeanPostProcessor。context:component-scan的base-package属性定义Spring自动实例化Bean的包(多个包用逗号隔开),其处理的注解有:@Component, @Service, @Repository, @Controller。