我正在尝试在我的自定义填充程序中覆盖addentries
中的BundleMiniCartPopulator
方法。
出现弹簧错误
错误[localhost-startStop-1] [ModifyPopulatorListBeanPostProcessor]无法查找名称为[customBundleMiniCartPopulator]的bean尝试将其添加到populator列表[miniCartConverter] org.springframework.beans.factory.BeanCreationException:创建名为'customBundleMiniCartPopulator的bean时出错'在类路径资源中定义[pilfacades-spring.xml]:设置属性值时出错;嵌套异常是org.springframework.beans.NotWritablePropertyException:bean类的无效属性'promotionResultConverter'[com.custom.b2c.ecommerce.facades.order.converters.populators.customBundleMiniCartPopulator]:Bean属性'promotionResultConverter'不可写或有无效的setter方法。 setter的参数类型是否与getter的返回类型匹配?
我尝试在我的populator中注入promotionresultconverter并生成setter方法。但我仍然得到同样的错误。有人可以告诉我如何解决这个问题吗?
答案 0 :(得分:0)
如果我们通过上面声明的bean的Spring bean父项(id =" customBundleMiniCartPopulator)的bean: " defaultBundleMiniCartPopulator"是" abstractBundleOrderPopulator"的孩子。这是" defaultAbstractSubscriptionOrderPopulator"的孩子。这是" baseOrderPopulator"的孩子。
现在" baseOrderPopulator" bean注入提到的属性(promotionResultConverter)。
Bean定义(包括promotionResultConverter属性)可以在下面看到(commercefacades-spring.xml):
<bean id="baseOrderPopulator"
class="de.hybris.platform.commercefacades.order.converters.populator.AbstractOrderPopulator"
abstract="true">
<property name="promotionResultConverter" ref="promotionResultConverter"/>
<property name="promotionsService" ref="promotionsService"/>
<property name="modelService" ref="modelService"/>
<property name="addressConverter" ref="addressConverter"/>
<property name="deliveryModeConverter" ref="deliveryModeConverter"/>
<property name="zoneDeliveryModeConverter" ref="zoneDeliveryModeConverter"/>
<property name="creditCardPaymentInfoConverter" ref="creditCardPaymentInfoConverter"/>
<property name="orderEntryConverter" ref="orderEntryConverter"/>
<property name="priceDataFactory" ref="priceDataFactory"/>
<property name="commonI18NService" ref="commonI18NService"/>
<property name="typeService" ref="typeService"/>
<property name="principalConverter" ref="principalConverter"/>
</bean>
与上述bean相关联的Java类(即AbstractOrderPopulator)具有字段(promotionResultConverter),以及关联的getter和setter:
protected Converter<PromotionResultModel, PromotionResultData> getPromotionResultConverter()
{
return promotionResultConverter;
}
@Required
public void setPromotionResultConverter(final Converter<PromotionResultModel, PromotionResultData> promotionResultConverter)
{
this.promotionResultConverter = promotionResultConverter;
}
作为结论,不需要创建field,setter和bean属性(pilfacades-spring.xml) JAVA类AbstractOrderPopulator(你继承)已经有了字段和 id =&#34; baseOrderPopulator&#34; (您继承)已经正确配置了该属性。