是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文檔(提示 - 他們完全是錯誤的答案;)。 –