forked from michaellavelle/spring-data-dynamodb
-
Notifications
You must be signed in to change notification settings - Fork 141
Multi Repository configuration
Sebastian J edited this page Jan 31, 2018
·
1 revision
Multiple repository factories try to register all repository interfaces with them - which doesn't work very well. Especially because spring-boot does a lot of auto-magic behind the curtain via the implicit existing @EnableJpaRepositories
.
The solution is to tell JPA and DynamoDB which repositories they are responsibility for (which then also drives which entities are registered):
For Spring-Boot:
@SpringBootApplication
@EnableJpaRepositories(includeFilters = {
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {CustomerRepository.class})
})
@EnableDynamoDBRepositories(includeFilters = {
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {DeviceValueRepository.class})
})
public class Application {
Same for a configuration class:
@Configuration
@EnableJpaRepositories(includeFilters = {
//or use basePackages or excludeFilters
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {CustomerRepository.class})
})
@EnableDynamoDBRepositories(includeFilters = {
//or use basePackages or excludeFilters
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {DeviceValueRepository.class})
})
public class AppConfig {
See also