Closed
Description
When I view the source code of MappingMongoConverterParser, I found duplicated bean injection, the source code is down here
RootBeanDefinition validatorDef = new RootBeanDefinition(
"org.springframework.validation.beanvalidation.LocalValidatorFactoryBean");
validatorDef.setSource(source);
validatorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
String validatorName = parserContext.getReaderContext().registerWithGeneratedName(validatorDef);
parserContext.registerBeanComponent(new BeanComponentDefinition(validatorDef, validatorName));
in line 5 it called method registerWithGeneratedName
, this method contains method registerBeanDefinition
, and this method return beanName of validatorDef
, which is 'org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0'.
in line 6, the method registerBeanComponent
also calles method registerBeanDefinition
with the same beanName, in Spring 5, beanDefinition overriding is not allowed by default value of false. When I run my application, it always throws BeanDefinitionOverrideException. I'm so confused about using spring-data-mongodb, can anybody help me explain this?