简体   繁体   English

在配置文件中分配值

[英]Assigning values in config file

I am having an application.conf file in resources of an SBT project. 我在SBT项目的资源中有一个application.conf文件。

How can I assign variables inside this file? 如何在此文件中分配变量?

For example: 例如:

project {
  fun1-version: "0.1.0-SNAPSHOT"
  fun2-version: "0.0.1-SNAPSHOT"
  fun3-version: "0.0.1-SNAPSHOT"
  fun4-version: "0.0.1-SNAPSHOT"

} }

So I do not want every time to change this 0.0.1 for each line. 因此,我不想每次都为每行更改此0.0.1 I have tried the following: 我尝试了以下方法:

versions {
  ver1 : "0.0.1"
}

project {
  fun1-version: ${versions.ver1}"-SNAPSHOT"
  fun2-version: ${versions.ver1}"-SNAPSHOT"
  fun3-version: ${versions.ver1}"-SNAPSHOT"
  fun4-version: ${versions.ver1}"-SNAPSHOT"
}

But it does not seem that it is working. 但是看来它没有用。 Any idea how can I do it? 知道我该怎么做吗?

Your config file is correct. 您的配置文件正确。 You need to call resolve() on your config object after loading it. 加载后,需要在配置对象上调用resolve()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM