【发布时间】:2013-03-12 09:13:29
【问题描述】:
我的要求是:我必须创建一个 AccountRepository 接口,并且我必须在我的 AccountRepositoryImpl 本身中实现所有方法,那么我该怎么做呢?
例子:
1) 接口
/* this is the interface */
public interface AccountRepository extends JpaRepository
{
List<Account> getAllAccounts();
}
2) 实施?
public class AccountRepositoryImpl implements AccountRepository
{
public List<Account> getAllAccounts() {
// now what?
}
}
【问题讨论】:
-
你有一个接口,现在实现它。你懂java吗?你的班级
AccountRepositoryImpl应该implements AccountRepository -
@Sotirios:实际上在 Spring Data 中,开发人员并没有实现接口。
标签: spring spring-data spring-data-jpa