I'm having some difficulties trying to understand the @Autowired annotation in Spring.
As I understood until now, I can , under some circumstance, declare @Autowired on an instance variable if I declare this variable class in the xml file where I keep the beans.
Under these circumstances, as I understood, I don't have to instanciate beans as they will get injected automatically declared by Spring. What I didn't understand is:
- I can declare in the xml for example one or more DAO beans that gets a connection as a parameter, but if I have to make different DAO's operations (for example get the user asking for the user DAO and then make another operation with another DAO) using the same instance of the connection?
- What is the difference in setting the
@Autowiredannotation in the constructor or in the setter methods?
Aucun commentaire:
Enregistrer un commentaire