Cosium / spring-data-jpa-entity-graph

Spring Data JPA extension allowing full dynamic usage of EntityGraph on repositories
MIT License
478 stars 49 forks source link

Repository bean not found #39

Closed Rahul1d closed 4 years ago

Rahul1d commented 4 years ago

Hi,

I am using spring jpa 2.2.6.RELEASE and spring-data-jpa-entity-graph 2.2.8. I have added @EnableJpaRepositories(repositoryFactoryBeanClass = EntityGraphJpaRepositoryFactoryBean.class) to config class.

Repository bean is Extending EntityGraphJpaRepository<T, Integer>,EntityGraphQuerydslPredicateExecutor.

I have followed all steps as mentiioned in the docs.

JPA Config. ` @Configuration @EnableJpaAuditing(auditorAwareRef = "auditorAware") @EnableJpaRepositories(repositoryFactoryBeanClass = EntityGraphJpaRepositoryFactoryBean.class) //@EnableJpaRepositories public class JpaConfig {

        @Bean
        public AuditorAware<String> auditorAware() {
            return new AuditorImpl();
        }

        @Bean
        public JPAQueryFactory jpaQueryFactory(EntityManager entityManager)
        {
            return new JPAQueryFactory(entityManager);
        }
        } `

Repository:.

        `
        public interface GeneralRepository<T> extends EntityGraphJpaRepository<T, Integer>,EntityGraphQuerydslPredicateExecutor<T> {

        }
        `
ylcinyakup commented 4 years ago

@Configuration @EnableJpaRepositories(repositoryFactoryBeanClass = EntityGraphJpaRepositoryFactoryBean.class, basePackages = {"com.dummy.app.repository"}) public class RepositoryConfig { }

reda-alaoui commented 4 years ago

Hi @ylcinyakup , @Rahul1d,

There must be something wrong with your Spring configuration. We used this version in production without issue.

If you can't provide your full application git repository, I can't help you.

ylcinyakup commented 4 years ago

i just write @Rahul1d questions answer :D he should set basePackages value

reda-alaoui commented 4 years ago

Oh ok @ylcinyakup :)

Rahul1d commented 4 years ago

The basePackage was missing . Thanks @ylcinyakup .

benodeveloper commented 1 year ago

@configuration @EnableJpaRepositories(repositoryFactoryBeanClass = EntityGraphJpaRepositoryFactoryBean.class, basePackages = {"com.dummy.app.repository"}) public class RepositoryConfig { } Life saver, this works well for me