当前位置:网站首页>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
边栏推荐
- Explanation and example application of the principle of logistic regression in machine learning
- Leetcode exercise - 396 Rotation function
- Difference between like and regexp
- redis-shake 使用中遇到的错误整理
- How to write the keywords in the cover and title? As we media, why is there no video playback
- 8.5 concise implementation of cyclic neural network
- Mds55-16-asemi rectifier module mds55-16
- nuxt项目:全局获取process.env信息
- Tencent has written a few words, Ali has written them all for a month
- Analysis of common storage types and FTP active and passive modes
猜你喜欢
8.3 language model and data set
Detailed explanation of kubernetes (IX) -- actual combat of creating pod with resource allocation list
Openfaas practice 4: template operation
LeetCode165-比较版本号-双指针-字符串
About UDP receiving ICMP port unreachable
分布式事务Seata介绍
How to design a good API interface?
我的树莓派 Raspberry Pi Zero 2W 折腾笔记,记录一些遇到的问题和解决办法
LeetCode 练习——396. 旋转函数
Leetcode162 - find peak - dichotomy - array
随机推荐
Detailed explanation of C language knowledge points -- data types and variables [1] - carry counting system
Kubernetes详解(十一)——标签与标签选择器
Baidu written test 2022.4.12 + programming topic: simple integer problem
深度学习——超参数设置
The win10 taskbar notification area icon is missing
Have you really learned the operation of sequence table?
Openfaas practice 4: template operation
Byte interview programming question: the minimum number of K
LeetCode162-寻找峰值-二分-数组
1n5408-asemi rectifier diode
每日一题-LeetCode396-旋转函数-递推
Krpano panorama vtour folder and tour
LeetCode167-两数之和II-双指针-二分-数组-查找
机器学习——逻辑回归
Design of digital temperature monitoring and alarm system based on DS18B20 single chip microcomputer [LCD1602 display + Proteus simulation + C program + paper + key setting, etc.]
Detailed analysis of SQL combat of Niuke database (26-30)
thinkphp5+数据大屏展示效果
大文件如何快速上传?
Flink datastream type system typeinformation
LeetCode151-颠倒字符串中的单词-字符串-模拟