是is said here,即要将一个单一方法添加到存储库,需要创建3(三个)类或接口。在Spring JPA中扩展接口以创建存储库的想法是什么?
这是真的,这样的曼波 - 缅博的目的是什么?接口扩展的唯一好处是能否通过命名约定来创建方法?这个好处是否真的超过了创造自己方法的能力的丧失?
UPDATE
为什么我不能做implements CrudRepository
?
我试图用implements
,
// does not work
//public abstract class CustomerRepository implements CrudRepository<Customer, Long> {
//
// abstract List<Customer> findByLastName(String lastName);
//}
// works
public interface CustomerRepository extends CrudRepository<Customer, Long> {
List<Customer> findByLastName(String lastName);
}
,但它不与错误工作
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'demo' defined in hello.Application: Unsatisfied dependency expressed through constructor argument with index 0 of type
[hello.CustomerRepository]: : No qualifying bean of type [hello.CustomerRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [hello.CustomerRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
这是一个凌乱的问题。你的代表表示你应该知道更多;)如何去除所有更新 - 因为你知道这是一个太宽泛的问题,我们需要解决?然后,我们可以去解释spring数据jpa,它基本上是在运行时自动生成实现的。 –
我对Spring比较陌生。每次我阅读他们的dox,我都有强烈的曼波 - 雅波姆感觉:) – Dims
春天是做任何事情的最简单的方法。如果你的胃部不舒服,试着阅读JEE文档(提示 - 他们完全是错误的答案;)。 –