DAOImpl接口(DAOImpl interfaces)

系统教程 行业动态 更新时间:2024-06-14 17:01:31
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

更多推荐

本文发布于:2023-04-20 16:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/91fc60f20278859055857c7719b828a1.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:接口   DAOImpl   interfaces

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!