Class ProductOptionValueImpl 的转换错误 - Broadleaf commerce

Class transformation errors with ProductOptionValueImpl - Broadleaf commerce

我开发了一个使用阔叶商务的应用程序。我尝试按照文档

实施动态定价

https://www.broadleafcommerce.com/docs/core/current/broadleaf-concepts/pricing/dynamic-pricing-configuration

我实现成功了,可以在eclipse中启动应用了。但是当我尝试在命令行中启动应用程序时出现以下错误

java.lang.IllegalStateException: The classes [org.broadleafcommerce.core.catalog.domain.ProductOptionValueImpl] are managed classes within the MergePersistenceUnitManager but were not detected as being transformed by the EntityMarkerClassTransformer. There can be multiple causes for this: 1. Session persistence is enabled in your servlet container (like Tomcat) and an entity object has been loaded by the container before being loaded by the application's classloader. Ensure that session persistence i s disabled; in Tomcat ensure that a element exists in your context.xml. 2. You are inadvertently using class scanning to find a ServletContainerInitializer class, and your servlet container is loading all classes before transformers have been registered. If you are using a web.xml, ensu re that there is an element somewhere in that file. If you are not using a web.xml and are using Spring Boot, then you likely need to add one. See https://www.broadleafcommerce.com/docs/core/5. 2/broadleaf-concepts/key-aspects-and-configuration/app-server-configuration/tomcat for the example web.xml 3. The classes are being used as apart of an @Bean method or in some other runtime capacity that is initialized prior to persistence manager startup

我尝试了第1点和第2点中提到的解决方案,但无法解决。

请帮助我摆脱这个异常。

编辑: 我已经实现了 DynamicSkuPricingService 接口,里面有一个使用 ProductOptionValueImpl 的覆盖方法。它实际上是在制造问题。

   @Service("ecomDynamicSkuPricingService")
    public class EcomDynamicSkuPricingServiceImpl implements DynamicSkuPricingService {
   ....
    @Override
    public DynamicSkuPrices getPriceAdjustment(ProductOptionValueImpl productOptionValueImpl, Money priceAdjustment,
            @SuppressWarnings("rawtypes") HashMap skuPricingConsiderationContext) {
   ....
   }
}

我不确定这是解决此问题的正确方法。但是我在我的自定义 DynamicSkuPricingFilter 中放置了以下代码片段,它解决了我的问题

@PostConstruct
public void init() {
    SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
}

我们可以通过 - 不使用@Autowired 或@Resource 在自定义 DynamicSkuPricingFilter 中注入 DynamicSkuPricingService,而是在我们需要的任何地方从 applicationcontext 获取 DynamicSkuPricingService bean。