-
Notifications
You must be signed in to change notification settings - Fork 78
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.