By default, the Spring context does not pay attention to @Autowired annotations. To process them, the context must have an AutowiredAnnotationBeanPostProcessor bean registered in the context.
<context:annotation-config/> registers one of them for you (along with several others), so you need it (unless you register AutowiredAnnotationBeanPostProcessor yourself, which is absolutely true).
If you don't like having @Autowired in your code, you can explicitly enter properties in XML using <property> , which simply moves the mess from one place to another.
If your context is extremely simple, you can use implicit auto-messaging, as described here . Essentially, this tells Spring to automatically auto-delete by property name or type. This required a very small configuration, but got out of hand very quickly - the automatic nature means that it is difficult to control and gives you very little flexibility.
@Autowired really the best option overall.
skaffman
source share