【问题标题】:How can a properties file be created using Talend Open Studio Data Integration?如何使用 Talend Open Studio Data Integration 创建属性文件?
【发布时间】:2016-06-14 17:53:20
【问题描述】:

我曾经使用 Talend Open Integration studio 来创建作业并从 IDE 运行它或将其导出为可执行的 jar 文件。但我没有广泛使用它。 是否可以创建一个包含不同服务器名称和其他变量的外部配置文件,以便在创建 Talend 作业的可执行 jar 文件后,我可以更改配置文本文件并选择不同的数据库服务器或端口选项?

我也使用了一点 MuleSoft,所以如果有人知道如何使用 MuleSoft 执行此操作,任何建议将不胜感激。

【问题讨论】:

    标签: java mule mule-studio talend


    【解决方案1】:

    使用 Talend,您可以在 Context 中定义参数。您可以使用组件tContextLoad 初始化一个上下文。

    如果您使用的是独立作业,则可以使用命令行参数 --context_param 设置或覆盖上下文值。

    【讨论】:

      【解决方案2】:

      从你的问题的内容,我会改写主题 “如何在 Talend Open Studio Data Integration 作业中读取和使用外部属性文件?”

      首先...创建您的属性文件“common.properties”。您可以将其放入(例如)/etc/classpath 或 c:\etc\classpath

      属性文件的示例内容

      example_property="This is an example property"
      

      在 Talend Project 中创建一个公共上下文并将相同的属性添加到该上下文中

      创建一个可重复使用的作业来读取属性并加载它们。我们称之为 Read_Properties。

      使用 tFileInputDelimited 组件来读取 props 文件。它应该使用“=”作为行分隔符。

      它应该有一个包含两列的架构

      key, string 
      value, string
      

      输出应该去一个 tBufferOutput

      现在...保存那个可重复使用的工作。

      创建一个新作业,example_calling_job。
      该作业应使用通用上下文。 该作业应该有一个预作业步骤,使用 tRunJob 调用属性作业,将行输出发送到 tContextLoad

      然后,您在 example_calling_job 中的组件可以使用属性读取器作业加载的上下文变量。

      运行 example_calling_job。 tJava 组件写出 context.example_property 值,该值由属性读取器作业加载到上下文变量中。

      Starting job example_calling_job at 11:35 02/03/2016.
      
      [statistics] connecting to socket on port 3497
      [statistics] connected
      This is an example property.
      [statistics] disconnected
      Job example_calling_job ended at 11:35 02/03/2016. [exit code=0]
      

      【讨论】:

        【解决方案3】:

        您可以使用 tFileOutputProperties 创建属性文件。在组件设置中指定.properties文件的文件路径。

        请注意,tFileOutputProperties 的输入模式应该只有两个字段 - 键和值。

        同样,要从 .properties 文件中读取,请使用 tFileInputProperties

        【讨论】:

        • 感谢@Ashok,您如何读取输入并调用连接器,例如 MySQL 连接服务器名称?
        猜你喜欢
        • 2013-10-18
        • 1970-01-01
        • 2021-11-01
        • 1970-01-01
        • 2023-01-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多