A T*_*riq 6 java extends jpa interface spring-data-jpa
TestRepository ***extends*** JpaRespotiroy<Test,Long>
JpaRepository 是一个接口。为什么我们要扩展它而不是像我们在 Java 中所知道的那样实现它?据我所知,接口是实现的,而不是扩展的。
有人可以向我解释一下吗?
我假设你的代码看起来像
interface TestRepository extends JpaRepository<Test, Long>
Run Code Online (Sandbox Code Playgroud)
所以 TestRepository 是一个接口,接口可以扩展其他接口而不是实现接口。
TestRepository 将在运行时基于 SimpleJpaRepository 从 Spring Data JPA 实现