带有冒号变量的类型安全配置覆盖 [英] Typesafe config override with colon-including variable
问题描述
我正在使用 Typesafe Config 来管理我的 Flink SQL 命令.例如,
I am using Typesafe Config to manage my Flink SQL command. For example,
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 中配置它
My properties.bootstrap.servers
is maven-profile specific, therefore I want to configure it in Maven pom.xml
<profiles>
<profile>
<id>testing</id>
<properties>
<kafka.source.servers>10.111.135.233:9092</kafka.source.servers>
</properties>
</profile>
</profiles>
我想在 Typesafe 配置中引用和使用该属性,
And I would like to reference and use the property in Typesafe config,
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' = '"""${kafka.source.servers}"""',
'properties.group.id' = 'flink-test2',
'json.fail-on-missing-field' = 'false',
'format' = 'json'
)
"""
但是,如果我运行 mvn clean package -Ptesting
,配置被内置到
However, if I run mvn clean package -Ptesting
, the config is built into
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'
)
"""
并且它在加载配置时抛出异常,因为 10.111.135.233:9092
包含一个 :
:
and it throws exceptions when loading the config, because 10.111.135.233:9092
contains a :
:
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
解决这个问题的正确方法是什么?谢谢!
What is the right way to solve this? Thanks!
推荐答案
我认为这是类型安全配置的问题.要解决此问题,请使用 application.properties
文件而不是 application.conf
.
I believe this is an issue from typesafe config. To solve the problem, use application.properties
file instead of application.conf
.
last-n-clicks.generation-ingestion.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' = '${kafka.source.servers}', \
'properties.group.id' = 'flink-test2', \
'json.fail-on-missing-field' = 'false', \
'format' = 'json' \
)
这篇关于带有冒号变量的类型安全配置覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!