Mule 如何在Dataweave2转换脚本中使用配置参数?

Mule 如何在Dataweave2转换脚本中使用配置参数?,mule,mule-studio,dataweave,anypoint-studio,mulesoft,Mule,Mule Studio,Dataweave,Anypoint Studio,Mulesoft,假设我有一个名为error messages.properties的配置文件。在此文件中,我有一个属性: error.invoice.missing.creationDate 当我试图直接将这个参数输入到DataWeave脚本中时,比如 "${error.invoice.missing.creationDate}" 我在脚本中得到一个错误: Unable to resolve reference of: `$`. 当我这样做的时候: "\${error.inv

假设我有一个名为
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脚本中工作?

使用p()函数引用配置属性

使用p()函数引用配置属性


如果这有助于实现您的目标,请接受此答案。这将有助于指导其他人今后提出类似的问题。如果这有助于你实现你的目标,请接受这一回答。这将有助于指导其他人今后提出类似的问题。