spring-cloud-dataflow - 如何在组合任务中设置我的应用程序属性?
问题描述
我有一个具有以下定义的组合任务:
task create my-task --definition "taskA && taskB"
当我启动任务并传递一个包含空格的值时,我想为taskA设置一个应用程序属性。同样,我需要为每个子任务设置 Spring 活动配置文件。
TaskA中应用程序属性的 Java 代码如下:
@ConfigurationProperties(prefix = "taskA")
public class TaskAProperties {
private String name;
... setter and getter
}
我尝试了许多命令,但无法使用空格。
task launch my-task --arguments "--composed-task-arguments=--spring.profiles.active=local --composed-task-properties=app.taskA.name='Bill Gates'"
当我打印出name属性时,它为空;
解决方案
在上面的示例中,我将使用属性而不是命令行参数。使用外壳,它看起来像:
task launch my-task --properties "app.my-task.taskA.spring.profiles.active=local,app.my-task.taskA.taska.name=Bill Gates"
. 更多信息可以在这里阅读。
我在您的示例中看到的一个问题是使用@ConfigurationProperties(prefix = "taskA")
. 使用 taskA 作为前缀是不正确的,你应该在你的应用程序中得到一个错误,说明类似 Modify 'taskA' so that it conforms to the canonical names requirements.
推荐阅读
- docker-compose - Traefik v2 和 Odoo:无需重启即可更新容器主机
- typescript - 使用 prisma 的 typescript 类型转换
- msbuild - 如何通过某种模式 CSPOJ 排除所有文件夹?
- javascript - JavaScript 基于外部对象的排序
- javascript - 如何找到带有特殊单词的句子?(问题:缩写和点)
- windows - x86_64 中有效调用堆栈的要求是什么?
- windows - 如何在不输出版本和版权信息的情况下启动 Windows CMD?
- android - 共享使用 SAF 创建的文件
- mysql - 没有重复的交叉连接表 - MYSQL
- ios - URL会话初始化问题