当前位置:网站首页>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
边栏推荐
- Detailed explanation of C language knowledge points -- first understanding of C language [1] - vs2022 debugging skills and code practice [1]
- Flink DataStream 类型系统 TypeInformation
- Common interview questions of operating system:
- tcp_ Diag kernel related implementation 1 call hierarchy
- Kubernetes详解(九)——资源配置清单创建Pod实战
- Little red book timestamp2 (2022 / 04 / 22)
- async void 导致程序崩溃
- Advanced version of array simulation queue - ring queue (real queuing)
- How to design a good API interface?
- How to write the keywords in the cover and title? As we media, why is there no video playback
猜你喜欢
LeetCode149-直线上最多的点数-数学-哈希表
Openfaas practice 4: template operation
X509 certificate cer format to PEM format
我的 Raspberry Pi Zero 2W 折腾笔记,记录一些遇到的问题和解决办法
Borui data and F5 jointly build the full data chain DNA of financial technology from code to user
Lotus DB design and Implementation - 1 Basic Concepts
Leetcode167 - sum of two numbers II - double pointer - bisection - array - Search
thinkphp5+数据大屏展示效果
函数(第一部分)
Leetcode149 - maximum number of points on a line - Math - hash table
随机推荐
Detailed explanation of C language knowledge points - data types and variables [2] - integer variables and constants [1]
Kubernetes详解(九)——资源配置清单创建Pod实战
[thymeleaf] handle null values and use safe operators
Redis master-slave synchronization
About UDP receiving ICMP port unreachable
C language super complete learning route (collection allows you to avoid detours)
redis-shake 使用中遇到的错误整理
Tun equipment principle
Daily question - leetcode396 - rotation function - recursion
On the day of entry, I cried (mushroom street was laid off and fought for seven months to win the offer)
Alexnet model
分享3个使用工具,在家剪辑5个作品挣了400多
Role of asemi rectifier module mdq100-16 in intelligent switching power supply
JS - implémenter la fonction de copie par clic
Collation of errors encountered in the use of redis shake
How does eolink help telecommuting
ffmpeg安装遇错:nasm/yasm not found or too old. Use --disable-x86asm for a crippled build.
22年了你还不知道文件包含漏洞?
HJ31 单词倒排
Borui data and F5 jointly build the full data chain DNA of financial technology from code to user