Before use it .You have to register an AutowiredAnnotationBeanPostProcessor instance in the IOC container.

-Have two way to register:

1. <context:annotation-config>

2. <bean class=”org.springframework.beans

.factory.annotation.AutowiredAnnotationBeanPostProcessor” />

Different  between @Autowired and @Resource:

– @Autowired wires by Type and specified by Spring . If you want to use wires by Name . Add @Qualifier.

-@Resource wires by Name and specified by Java

Advertisements