当前位置:网站首页>YML references other variables
YML references other variables
2022-04-23 15:14:00 【A run】
Reference resources :YAML file (.yml) The key (key) Set... By variable reference - i People in the Jianghu - Blog Garden
Set the configuration quantity through variable reference 【 value (value)】
stay YAML In file , A configuration quantity value You can set... By referring to another variable . for example :
default-db:
port: 3306
user-db:
port: ${default-db.port}
however , If you want to set through variable reference key , adopt ${} It can't be done . for example :
site:
url:
user: www.user.net
shop: www.shop.net
site:
slogan:
${site.url.user}: everyone is great!
${user.url.shop}: buy anything you want!
After reading the configuration into the program , You will find the above ${} quote , Not replaced with a real value .
Set the configuration amount through the anchor point reference 【 key (key)】
To replace keys , You need to use anchors . The anchor point is marked with “&” Definition , And use symbols “*” reference .
There are two ways to use anchors , One is to pass. “<<:” Introduce key value pairs into :
default-db: &default-db-config
host: 127.0.0.1
port: 3306
user-db:
<<: *default-db-config
The actual effect is as follows :
default-db:
host: 127.0.0.1
port: 3306
user-db:
host: 127.0.0.1
port: 3306
explain :& The following anchor name , You can define , It does not have to be the same as the key of the configuration quantity .
The other is Only the configured values are introduced :
site:
url:
user: &site.user www.user.net
shop: &site.shop www.shop.net
site:
slogan:
*site.user: everyone is great!
*site.shop: buy anything you want!
The actual effect is as follows :
site:
url:
user: www.user.net
shop: www.shop.net
site:
slogan:
www.user.net: everyone is great!
www.shop.net: buy anything you want!
explain : use & When defining anchors , Notice the space before and after the anchor name .
Another example of introducing only values :
color:
- &red-color red
- yellow
- blue
- *red-color
- gray
The actual effect is as follows :
color:
- red
- yellow
- blue
- red
- gray
Reference documents :
版权声明
本文为[A run]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231407312850.html
边栏推荐
- Krpano panorama vtour folder and tour
- Alexnet model
- API gateway / API gateway (III) - use of Kong - current limiting rate limiting (redis)
- A series of problems about the best time to buy and sell stocks
- Llvm - generate addition
- 1n5408-asemi rectifier diode
- Collation of errors encountered in the use of redis shake
- adobe illustrator 菜单中英文对照
- js——实现点击复制功能
- Introduction to dirty reading, unrepeatable reading and phantom reading
猜你喜欢
Leetcode153 - find the minimum value in the rotation sort array - array - binary search
大文件如何快速上传?
Tencent has written a few words, Ali has written them all for a month
重定向和请求转发详解
Reptile exercises (1)
Detailed explanation of kubernetes (IX) -- actual combat of creating pod with resource allocation list
让阿里P8都为之着迷的分布式核心原理解析到底讲了啥?看完我惊了
Sword finger offer (2) -- for Huawei
Design of digital temperature monitoring and alarm system based on DS18B20 single chip microcomputer [LCD1602 display + Proteus simulation + C program + paper + key setting, etc.]
8.2 text preprocessing
随机推荐
如何设计一个良好的API接口?
What is the role of the full connection layer?
Mysql连接查询详解
setcontext getcontext makecontext swapcontext
Tencent has written a few words, Ali has written them all for a month
Will golang share data with fragment append
Grep was unable to redirect to the file
8.2 text preprocessing
How does eolink help telecommuting
大文件如何快速上传?
LeetCode165-比较版本号-双指针-字符串
Role of asemi rectifier module mdq100-16 in intelligent switching power supply
js——實現點擊複制功能
深度学习——超参数设置
如何设计一个良好的API接口?
HJ31 单词倒排
API gateway / API gateway (III) - use of Kong - current limiting rate limiting (redis)
How to design a good API interface?
thinkphp5+数据大屏展示效果
Leetcode151 - invert words in string - String - simulation