带有冒号变量

问题描述

我正在使用 Typesafe Config 来管理我的 Flink SQL 命令。例如,

source = """
CREATE TABLE kafka_source (
    `body` ROW<`log` ROW<`uid` BIGINT,serverts BIGINT,`contentstr` STRING>>
) WITH (
    'connector' = 'kafka','topic' = 'data-report-stat-old-logtype7','properties.bootstrap.servers' = '10.111.135.233:9092','properties.group.id' = 'flink-test2','json.fail-on-missing-field' = 'false','format' = 'json'
)
"""

我的 properties.bootstrap.servers 是 maven-profile 特定的,因此我想在 Maven pom.xml 中配置它

<profiles>
    <profile>
        <id>testing</id>
        <properties>
            <kafka.source.servers>10.111.135.233:9092</kafka.source.servers>
        </properties>
    </profile>
</profiles>

我想在 Typesafe 配置中引用和使用该属性,

source = """
CREATE TABLE kafka_source (
    `body` ROW<`log` ROW<`uid` BIGINT,'properties.bootstrap.servers' = '"""${kafka.source.servers}"""','format' = 'json'
)
"""

但是,如果我运行 mvn clean package -Ptesting,配置被内置到

source = """
CREATE TABLE kafka_source (
    `body` ROW<`log` ROW<`uid` BIGINT,'properties.bootstrap.servers' = '"""10.111.135.233:9092"""','format' = 'json'
)
"""

并且在加载配置时抛出异常,因为 10.111.135.233:9092 包含一个 :

Expecting close brace } or a comma,got ':' (if you intended ':' to be part of a key or string value,try enclosing the key or value in double quotes

解决这个问题的正确方法是什么?谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)