Spring Cloud Data Flow 应用程序中的应用程序属性 [英] App properties in Spring Cloud Data Flow application

查看:33
本文介绍了Spring Cloud Data Flow 应用程序中的应用程序属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于 Spring Cloud Data Flow (SCDF) 的文档,仅以已部署"为前缀的属性.或应用程序".在将应用程序(无论是源、处理器还是接收器)部署为流的一部分时会考虑.

Based on the documentation for Spring Cloud Data Flow (SCDF) only properties that are prefixed by either "deployed." or "app." are considered when deploying an application (be it a source, processor or sink) as part of a stream.

但是,我注意到除了前缀之外,所有属性都必须以字符串"的形式提供,无论它们的原始类型是什么;否则,它们会被 SCDF 按照这行代码简单地丢弃:

However, I've noticed that besides the prefix, all the properties must be provided as "strings", no matter what their original type is; otherwise, they are simply discarded by SCDF as per this line of code:

    propertiesToUse = DeploymentPropertiesUtils.convert(props);

这样做:

public static Map<String, String> convert(Properties properties) {
    Map<String, String> result = new HashMap<>(properties.size());
    for (String key : properties.stringPropertyNames()) {
        result.put(key, properties.getProperty(key));
    }
    return result;
}

正如您从上面的代码片段中看到的,它只考虑stringPropertyNames",它过滤掉了任何未作为String"提供的内容.

As you can see from the snippet above, it only considers "stringPropertyNames" which filters out anything that is not provided as a "String".

我认为这种行为是故意的,但为什么呢?为什么不直接选取用户定义的所有带有适当前缀的属性?

I presume this behaviour is intentional, but why? Why not just pick up all the properties defined by the user with the proper prefix?

感谢您的支持.

推荐答案

所有部署属性都应该是 Map 基于 合同 由部署者 SPI 设置.

All the deployment properties are expected to be of Map<String, String> based on the contract set by the deployer SPI.

我相信原因之一是拥有 String 键,值被传递到目标部署平台而没有序列化/反序列化障碍.并且,使用字符串值类似于如何在目标部署平台中将这些键值属性设置为环境变量(例如).

I believe one of the reasons is to have String key, values being passed to target deployment platform without serialization/de-serialization hurdle. and, using String values is similar to how one could set those key, value properties as environment variables (for example) in the target deployment platform.

这篇关于Spring Cloud Data Flow 应用程序中的应用程序属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆