spring-projects / spring-projects/spring-data-keyvalue

Revisit configuration model of KeyValueRepositoryConfigurationExtension

Open
#363 0 comments 0 reactions 1 assignee View on GitHub

@mp911de is already working on this.

Since Oct 2, 2025.

  • #653 by @mp911de — open
in: repository
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.