簡體   English   中英

在Mule中讀取YAML文件

[英]Reading a YAML file in Mule

我在讀取由MuleSoft中的列表組成的YAML文件時遇到問題。

我將YAML文件設置為以下結構中的“全局元素”中的“配置”屬性。

applications:
  - appId: "123456"
    appName: Application One
  - appId: "456789"
    appName: Application Two

沒有列表時,我能夠讀取值。 但是,當我將其設置為列表時,MuleSoft會引發此錯誤:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Failed to deploy artifact 'test', see below        +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
org.mule.runtime.deployment.model.api.DeploymentException: Failed to deploy artifact [test]
Caused by: org.mule.runtime.api.exception.MuleRuntimeException: org.mule.runtime.deployment.model.api.DeploymentInitException: ConfigurationPropertiesException: Configuration properties does not support type a list of complex types. Complex type keys are: appId,appName
Caused by: org.mule.runtime.deployment.model.api.DeploymentInitException: ConfigurationPropertiesException: Configuration properties does not support type a list of complex types. Complex type keys are: appId,appName
Caused by: org.mule.runtime.core.api.config.ConfigurationException: Configuration properties does not support type a list of complex types. Complex type keys are: appId,appName
Caused by: org.mule.runtime.config.internal.dsl.model.config.ConfigurationPropertiesException: Configuration properties does not support type a list of complex types. Complex type keys are: appId,appName

請幫助我:這不是使用YAML文件的正確方法嗎? 我需要更改格式嗎?

謝謝!

配置屬性不支持作為復雜類型列表的類型。 必須在后端將屬性轉換為彈簧屬性

您只能使用簡單的列表:應用程序:-“ 123456”-“ 456789”

但是,簡單的對象對於屬性也同樣適用:

applications:
  "123456":
      name: Application One
  "456789":
      name: Application Two

然后,您可以通過appId動態查找,例如:

<set-variable variableName="appId" value="123456"  />
<logger level="INFO" message="#[p('applications.' ++ vars.appId ++ '.name')]" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM