darrachequesne / spring-data-jpa-datatables

Spring Data JPA extension to work with the great jQuery plugin DataTables (https://datatables.net/)
Apache License 2.0
451 stars 172 forks source link

*** required a bean of type ***Repository that could not be found. #111

Closed hasanli-orkhan closed 1 year ago

hasanli-orkhan commented 4 years ago

Hello, dear developer! Faced the following problem: After adding your library to your project and adding configuration, I get an error:

***************************
APPLICATION FAILED TO START
***************************
Description:
Field translationRepository in info.md7.freelance.tools.DBMessageSource required a bean of type 'info.md7.freelance.repos.TranslationRepository' that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:
Consider defining a bean of type 'info.md7.freelance.repos.TranslationRepository' in your configuration.

I tried this configs:

@Configuration
@EnableJpaRepositories(basePackages = "info.md7.freelance.datatables")
public class DataTablesConfiguration {
}
@Configuration
@EnableJpaRepositories(repositoryFactoryBeanClass = DataTablesRepositoryFactoryBean.class, basePackages = "info.md7.freelance.datatables")
public class DataTablesConfiguration {
}

And get the same error... I want to initialize DataTablesRepositoryImpl only in the specified packages, but get exception for repos that are in the package info.md7.freelance.repos

How I can fix it?

kapil-signity commented 4 years ago

I need same solution? @Auther

thachpholly commented 4 years ago

I got same your problem. How can solve it?

johnnyboi91 commented 2 years ago

I see this is a bit older but still... It looks like you need to add another configuration class to enable your other repositories, so from your example it should be something like:

@Configuration
@EnableJpaRepositories(basePackages = "info.md7.freelance.repos")
public class JpaConfiguration {
}

Hope this helps!

thiemt-armando commented 1 year ago

Can confirm this works just like johnnyboi91 mentioned

@Configuration
@EnableJpaRepositories(basePackages = "your.repository")

is enough, if you put it in your main class file, where your project launches.

darrachequesne commented 1 year ago

@thiemt-armando thanks a lot for the feedback :+1:

I think we can close this now, please reopen if needed.