我試圖添加屬性「集合」以顯示在hybris B2C加速器的前端。綁定不匹配錯誤
到目前爲止,我宣佈我的項目名 - Spring.xml文件以下豆類:
<alias name="defaultProductSpecialPopulator" alias="productSpecialPopulator" />
<bean id="defaultProductSpecialPopulator" class="de.hybris.electronics.facades.populators.ProductSpecialPopulator" scope="prototype">
<property name="modelService" ref="modelService" />
</bean>
<alias name="defaultProductConfiguredPopulator" alias="productConfiguredPopulator" />
<bean id="defaultProductConfiguredPopulator" class="de.hybris.platform.commercefacades.converter.impl.DefaultConfigurablePopulator">
<property name="populators">
<map key-type="de.hybris.platform.commercefacades.product.ProductOption">
<entry key="SPECIAL" value-ref="productSpecialPopulator" />
</map>
</property>
</bean>
在我的項目名 - core.xml文件,我添加的屬性集合:
<typegroup name="Product">
<itemtype code="Product" autocreate="false" generate="false">
<description>Pending description...</description>
<attributes>
<attribute qualifier="collection" type="java.lang.String">
<description>Pending description...</description>
<persistence type="property"></persistence>
</attribute>
</attributes>
</itemtype>
</typegroup>
但是,當我實施populator時,出現以下錯誤:
Bound mismatch: The type TARGET is not a valid substitute for the bounded parameter of the type AbstractProductPopulator
這裏是populator問題:
package de.hybris.electronics.facades.populators;
import de.hybris.electronics.facades.product.data.ProductData;
import de.hybris.platform.commercefacades.product.converters.populator.AbstractProductPopulator;
import de.hybris.platform.core.model.product.ProductModel;
import de.hybris.platform.servicelayer.dto.converter.ConversionException;
public class ProductSpecialPopulator<SOURCE extends ProductModel, TARGET extends ProductData>
extends AbstractProductPopulator<SOURCE, TARGET>
{
@Override
public void populate(final ProductModel source, final ProductData target) throws ConversionException
{
target.setCollection(source.getCollection());
}
}
錯誤本身是由目標在此行拋出:
extends AbstractProductPopulator<SOURCE, TARGET>
而這裏的AbstractProductPopulator的定義:
public abstract class AbstractProductPopulator<SOURCE extends ProductModel, TARGET extends ProductData>
implements Populator<SOURCE, TARGET>
此AbstractProductPopulator不是您公開發布的內容它的類定義(即公共抽象類AbstractProductPopulator ...') – 2017-08-31 08:23:18
當然,我將編輯帖子以包含Abstract populator的定義。 –
查看ProductData的名稱空間和AbstractProductPopulator中的名稱空間。他們可能不同。如果您使用Hybris 6+,我建議您只擴展ProductPopulator –