假设我有2个YAML文件:
1)application.yml
en:
variable: "Hello World"
2)user.yml
en:
variable: <Here I want to get value from application.yml -> "Hello World" >
起初我虽然可以使用引用:
1)application.yml
en:
variable: &variable "Hello World"
2)user.yml
en:
variable: *variable
但是事实证明,只有在一个文件中声明的项目才有可能。
有什么办法可以从application.yml中定义的变量中获取值?
最佳答案
So the only way is to create another, third file that would hold shared values. Or to use the value from "application.yml".
YAML references are intra-file.
You could also have a preprocessing step where you merge YAML files.
在* nix shell中:
cat foo.yaml bar.yaml > baz.yaml
在Powershell中:
cat foo.yaml, bar.yaml > baz.yaml
批量:
type foo.yaml bar.yaml > baz.yaml
引用
关于string - YAML引用另一个文件中的另一个变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22639727/