当前位置:网站首页>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
边栏推荐
- Leetcode149 - maximum number of points on a line - Math - hash table
- LeetCode149-直线上最多的点数-数学-哈希表
- My raspberry PI zero 2W toss notes to record some problems and solutions
- 机器学习——逻辑回归
- Collation of errors encountered in the use of redis shake
- Leetcode153 - find the minimum value in the rotation sort array - array - binary search
- The win10 taskbar notification area icon is missing
- [thymeleaf] handle null values and use safe operators
- MySQL sync could not find first log file name in binary log index file error
- Three uses of kprobe
猜你喜欢
How does eolink help telecommuting
Krpano panorama vtour folder and tour
Leetcode151 - invert words in string - String - simulation
Share 20 tips for ES6 that should not be missed
函数(第一部分)
My raspberry PI zero 2W tossing notes record some problems encountered and solutions
中富金石财富班29800效果如何?与专业投资者同行让投资更简单
免费在upic中设置OneDrive或Google Drive作为图床
LeetCode149-直线上最多的点数-数学-哈希表
API gateway / API gateway (III) - use of Kong - current limiting rate limiting (redis)
随机推荐
On the day of entry, I cried (mushroom street was laid off and fought for seven months to win the offer)
win10 任务栏通知区图标不见了
Comparaison du menu de l'illustrateur Adobe en chinois et en anglais
API gateway / API gateway (II) - use of Kong - load balancing
MySQL InnoDB transaction
Detailed explanation of C language knowledge points - data types and variables [2] - integer variables and constants [1]
Lotus DB design and Implementation - 1 Basic Concepts
Is asemi ultrafast recovery diode interchangeable with Schottky diode
函数(第一部分)
What is the role of the full connection layer?
How to write the keywords in the cover and title? As we media, why is there no video playback
每日一题-LeetCode396-旋转函数-递推
Detailed explanation of kubernetes (XI) -- label and label selector
Detailed explanation of kubernetes (IX) -- actual combat of creating pod with resource allocation list
Basic operation of circular queue (Experiment)
LeetCode 练习——396. 旋转函数
Set onedrive or Google drive as a drawing bed in upic for free
Kubernetes详解(十一)——标签与标签选择器
Byte interview programming question: the minimum number of K
January 1, 1990 is Monday. Define the function date_ to_ Week (year, month, day), which realizes the function of returning the day of the week after inputting the year, month and day, such as date_ to