【问题标题】:Set property value like part of another property in YAML config spring boot将属性值设置为 YAML 配置 spring boot 中另一个属性的一部分
【发布时间】:2018-10-15 12:47:57
【问题描述】:

我有带有属性的 YAMl 配置文件:

send-executor:
    thread-max-count: 5

我还有另一个财产:

ready-query: SELECT * From ...(another conditions).. where ROWNUM >= 5

我可以在ROWNUM >= 5我的另一个属性thread-max-count中设置5吗?

类似这样的:

ready-query: SELECT * From ...(another conditions).. where ROWNUM >= {$thread-max-count}

或者我需要设置占位符并仅在 java 代码中进行更改?

【问题讨论】:

  • 您可以使用 @Value("${thread-max-count}") 然后在查询中使用该变量。

标签: spring-boot yaml spring-config


【解决方案1】:

是的,你可以。这个语法是${send-executor.thread-max-count}

【讨论】:

    猜你喜欢
    • 2021-03-06
    • 2017-08-20
    • 2018-08-25
    • 1970-01-01
    • 2015-12-21
    • 1970-01-01
    • 2017-11-07
    • 1970-01-01
    • 2021-01-16
    相关资源
    最近更新 更多