bean属性重复赋值问题
vow0824 opened this issue · 1 comments
vow0824 commented
com.vow.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator#postProcessPropertyValues的方法是不是应该返回null,com.vow.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#doCreateBean在执行到applyBeanPostProcessorsBeforeApplyingPropertyValues(beanName, bean, beanDefinition);的时候会将InstantiationAwareBeanPostProcessor实现类返回的属性重复add到BeanDefinition#propertyValues属性列表中(beanDefinition.getPropertyValues().addPropertyValue(propertyValue);),会重复赋值
ZwxwZ commented
我觉得好的修改方法应该是修改 PropertyValues 的addPropertyValue方法
public void addPropertyValue(PropertyValue pv) {
this.propertyValueList.removeIf(propertyValue -> pv.getName().equals(propertyValue.getName()));
this.propertyValueList.add(pv);
}