如何解决如何在 DataWeave 2 转换脚本中使用配置参数?
假设我有一个名为 error-messages.properties
的配置文件。在这个文件中,我有一个属性:
error.invoice.missing.creationDate
当我尝试将此参数直接输入到 DataWeave 脚本中时,例如
"${error.invoice.missing.creationDate}"
我在脚本中遇到错误:
Unable to resolve reference of: `$`.
当我这样做时:
"\${error.invoice.missing.creationDate"
我在脚本中没有发现任何错误,但是当我尝试运行此代码时,稍后又出现了相同的错误:
import fail from dw::Runtime
output application/java
ns ns0 com.app.invoice/Invoice
var isPresent = (value,message: String) -> if (value == null or isEmpty(value)) fail(message) else value
---
{
creationDate: isPresent(payload.invoice.creationTime,"${error.invoice.missing.creationDate}")
} as Object {
class : "domain.command.InvoiceCommand"
} ' has errors:
Unable to resolve reference of $. at 9 : 9" evaluating expression: "%dw 2.0
如何将我的变量正确放入 DW 脚本中?我知道 "${some.param}"
可以在 XML 文件中使用,但如何在 DW2.0 脚本中使用?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。