This week I've been trying to learn Spring, JBoss, Maven, JPA and Hibernate and I've had a lot of fun with it. I am somewhat confused over the many different ways to inject resources in a class though. Until this week I was not even aware that you could inject resources in any other way than using the <property>
tag in your Spring XML configuration.
<bean id="catalogService" class="com.idbs.omics.catalog.service.CatalogService">
<property name="termDao" ref="termDao"></property>
</bean>
When I started experimenting with JPA I encountered @PersistenceContext
, but that seems to be a special case so fair enough. Then I started reading up on Spring's testing framework and I saw the first example that used @Resource(name="catalogService")
and then in a Web Service example @Autowired
crashed the party!
**The Question!**
So what is the difference between all these and is there right and wrong situation to use them in? I guess I'm looking for a best practice here.
Cheers all