Tuesday, December 2, 2008

@Resource and @Autowired

In September I wrote an article on using @Autowired for testing RMI services in Spring. Recently when trying to test a webservice consumer, I ran into trouble with @Autowired. Instead using @Resource (javax.annotation.Resource in Java 1.6) seemed to work fine. Digging I found this article in Spring forum:


which pointed to this in spring reference:

Seems the two are pretty similar. Using 
@Qualifier (org.springframework.beans.factory.annotation.Qualifier) with @Autowired solved the problem and in the end I could use either. 

No comments: