Spring boot 带有Spring数据的泛型Dao

Spring boot 带有Spring数据的泛型Dao,spring-boot,spring-data-jpa,Spring Boot,Spring Data Jpa,我在Spring boot项目中使用Spring数据存储库和自定义存储库,但我想为自定义添加通用存储库 这是GenericCustomRepositoy: 有件事我做错了 我更改了代码,添加了一个自定义存储库,扩展了泛型,但得到了相同的异常 这是新的存储库: @Repository public interface AdresseLivraisonRepository extends JpaRepository<AddressEntity, Integer>, GenericCust

我在Spring boot项目中使用Spring数据存储库和自定义存储库,但我想为自定义添加通用存储库

这是GenericCustomRepositoy:

有件事我做错了

我更改了代码,添加了一个自定义存储库,扩展了泛型,但得到了相同的异常

这是新的存储库:

@Repository
public interface AdresseLivraisonRepository extends JpaRepository<AddressEntity, Integer>, GenericCustomRepositoy<AddressEntity, Integer> {

}
@Repository
public interface AdresseLivraisonRepository extends JpaRepository<ForwardingAddressEntity, Integer>, AdresseLivraisonCustomRepository {

}

自定义查询方法的名称遵循Spring数据JPA存储库的命名约定。所以SpringDataJPA试图在启动期间为它生成一个查询方法


尝试将您的方法重命名为其他方法,如genericFindByFields…

好吧,我用Spring Data JpaSpecificationExecutor更改了我的泛型类,它完成了我想对泛型执行的操作

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adresseLivraisonRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property fields found for type AddressEntity!
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
@Repository
public interface AdresseLivraisonRepository extends JpaRepository<ForwardingAddressEntity, Integer>, AdresseLivraisonCustomRepository {

}