DAOImpl接口(DAOImpl interfaces)
在Spring中,在创建DAO类来访问数据库时,我还实现了DAO接口。 即:
public interface EmployeeDAO { public void addEmployee(Employee emp); } @Repository public class EmployeeDAOImpl implements EmployeeDAO { public void addEmployee(Employee emp) { /* code here */ } }为什么要实现接口? 为什么“公共级员工DAOImpl”还不够? 谢谢。
In Spring, while creating a DAO class to access to database, i also implement a DAO interface. i.e. :
public interface EmployeeDAO { public void addEmployee(Employee emp); } @Repository public class EmployeeDAOImpl implements EmployeeDAO { public void addEmployee(Employee emp) { /* code here */ } }Why do we implement an interface? Why "public class EmployeeDAOImpl" is not enough? Thank you.
最满意答案
这个问题与这个链接几乎相似
使用接口编写DAO类
我希望这会清除你的怀疑
this question is almost similar to this link
Using interfaces for writing DAO classes
I hope this will clear your doubt
更多推荐
发布评论