Configuring injection relationships with annotation
To better explain the meaning of this kind of existence, the following is a description of the problem through a habitual development, for example:
Now there is a Iadminservice service layer, the service layer to invoke is the Iadmindao and Iroledao two data-tier operations, so defined as follows:
Example: Define a data-tier operation.
Package com. Spring.dao; Public Interface Iadmindao { public boolean findlogin ();}
And
Package com. Spring.dao; Public Interface Iroledao { publicboolean findAll ();}
Implementation layer:
Package com. SPRING.DAO.IMP; Import com. Spring.Dao.IAdminDAO; Public class Implements Iadmindao { @Override publicboolean findlogin () { System.out.println ("[Iadmindao]public boolean Findlogin ()"); return false ; }}
And
Package com. SPRING.DAO.IMP; Import com. Spring.Dao.IRoleDAO; Public class Implements Iroledao { @Override publicboolean findAll () { System.out.println ("[Iroledao]public boolean FindAll ()"); return false ; }}
At the earliest, these two data-tier classes must write factory classes, one-way now without writing factory classes.
The following is defined directly in the Appllicationcontext.xml file.
class= "com. Spring.Dao.Imp.AdminDAOImpl "></bean> class=" com. Spring.Dao.Imp.RoleDAOImpl "></bean>
Then all the data layers are assigned to the business layer, so the following defines the business layer operations:
08-spring Learning-annotation Configuration