spring-projects / spring-projects/spring-data-keyvalue
Revisit configuration model of KeyValueRepositoryConfigurationExtension
- Dominant language
- Java
- Stars
- 157
- Forks
- 85
- PR merge metrics
- No merged PRs in 30d
Description
KeyValueRepositoryConfigurationExtension (enabled through @EnableMapRepositories or @EnableRedisRepositories) attempts to create default beans if there are no bean definitions already registered. This happens mostly for KeyValueTemplate and the MappingContext.
For Redis, there are a couple more beans involved. When using multiple configuration classes, the processing of KeyValueRepositoryConfigurationExtension depends on the actual order in which bean registrations are been made. Defining a template bean in one config class and declaring @EnableMapRepositories on a different class can lead to the state where KeyValueRepositoryConfigurationExtension does not yet see the bean declaration and thus two beans get registered.
We should back off from this type of defaulting and ideally try to reduce the number of required beans. Besides that, we should investigate a configuration model that tries to supply missing beans/components through a BeanPostProcessor.
In the case of Map repositories:
Check whether a KeyValueRepositoryFactoryBean is associated with a MappingContext/QueryCreator/KeyValueOperations prior to bean initialization so that defaulting applies as late as possible.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.