代码改变世界

spring 让@Autowired 注释工作起来

2011-02-22 15:44  myjava2  阅读(189)  评论(0编辑  收藏  举报

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

    <!-- 该 BeanPostProcessor 将自动起作用,对标注 @Autowired 的 Bean 进行自动注入 -->
    <bean class="org.springframework.beans.factory.annotation.
        AutowiredAnnotationBeanPostProcessor"/>


<!-- Activates scanning of @Autowired -->
    <context:annotation-config/>

 

    <!-- Activates scanning of @Repository and @Service -->
    <context:component-scan base-package="com.ibm"/>
   </beans>