绑定不匹配错误
Bound Mismatch Error
我正在尝试添加属性 "Collection" 以显示在 hybris B2C 加速器的前台。
到目前为止,我已经在我的 projectName-Spring.xml 文件中声明了以下 Bean:
<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>
在我的 ProjectName-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>
但是,当我实现填充器时,出现以下错误:
Bound mismatch: The type TARGET is not a valid substitute for the
bounded parameter of the type
AbstractProductPopulator
这里是有问题的填充器:
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());
}
}
此行中的 TARGET 本身引发错误:
extends AbstractProductPopulator<SOURCE, TARGET>
这里是 AbstractProductPopulator 的定义:
public abstract class AbstractProductPopulator<SOURCE extends ProductModel, TARGET extends ProductData>
implements Populator<SOURCE, TARGET>
我认为问题是由 ProductSpecialPopulator 使用 de.hybris.electronics.facades.product.data.ProductData 引起的
和 AbstractProductPopulator 最有可能使用 de.hybris.platform.commercefacades.product.data.ProductData,
因此这是两个不同的 classes(包不同但名称,即 ProductData 相同)导致错误。
很可能有一个 extensionName-beans.xml 文件,其中 ProductData 的 bean 定义如下 class="de.hybris.electronics.facades.product.data.ProductData"
而不是 class="de.hybris.platform.commercefacades.product.data.ProductData",这应该是向现有的 hybris 产品数据
添加属性的正确方法
我正在尝试添加属性 "Collection" 以显示在 hybris B2C 加速器的前台。
到目前为止,我已经在我的 projectName-Spring.xml 文件中声明了以下 Bean:
<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>
在我的 ProjectName-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>
但是,当我实现填充器时,出现以下错误:
Bound mismatch: The type TARGET is not a valid substitute for the bounded parameter of the type AbstractProductPopulator
这里是有问题的填充器:
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());
}
}
此行中的 TARGET 本身引发错误:
extends AbstractProductPopulator<SOURCE, TARGET>
这里是 AbstractProductPopulator 的定义:
public abstract class AbstractProductPopulator<SOURCE extends ProductModel, TARGET extends ProductData>
implements Populator<SOURCE, TARGET>
我认为问题是由 ProductSpecialPopulator 使用 de.hybris.electronics.facades.product.data.ProductData 引起的
和 AbstractProductPopulator 最有可能使用 de.hybris.platform.commercefacades.product.data.ProductData,
因此这是两个不同的 classes(包不同但名称,即 ProductData 相同)导致错误。
很可能有一个 extensionName-beans.xml 文件,其中 ProductData 的 bean 定义如下 class="de.hybris.electronics.facades.product.data.ProductData" 而不是 class="de.hybris.platform.commercefacades.product.data.ProductData",这应该是向现有的 hybris 产品数据
添加属性的正确方法