首页 > 解决方案 > Freemarker 表达未定义

问题描述

我在模板中有以下freemarker:

${root.product.getInventoryReference(channel)}

在eclipse中运行我的应用程序时它工作正常但是当我运行编译版本时我得到错误:

Expression root.product.getInventoryReference(channel) is undefined on line 3, column 28 in rtd.integration.builder.ApiOperationConfigurationKeySource@b701440-sourceTemplate.
The problematic instruction:
----------
==> ${root.product.getInventoryReference(channel)} [on line 3, column 26 in rtd.integration.builder.ApiOperationConfigurationKeySource@b701440-sourceTemplate]
----------

我的产品对象具有如下 getInventoryReference 方法:

public class Product extends ... {
   ...
   public String getInventoryReference(Channel channel) {
    ChannelProduct selectedChannelProduct = getChannelProduct(channel);
    if (selectedChannelProduct != null) {
      return selectedChannelProduct.getInventoryReference();
    }
    return null;
  }
  ...
}

我知道 product、root 和 channel 不为空,因为我能够从同一模板中的 root.product 访问其他方法,并在其他地方使用 channel。

我还检查了我的应用程序的构建版本中的产品类文件实际上确实具有该方法。反编译后我可以确认是这种情况。

有没有人对为什么这可能会失败有任何其他想法?谢谢

标签: javafreemarker

解决方案


推荐阅读