SpringBoot使用一个全局的配置文件,配置文件名是固定的;
•application.properties
•application.yaml(yml)
springboot新建工程默认使用的是properties格式,但实际开发中使用yaml的居多
普通的值(数字,字符串,布尔)
port: 8081
对象、Map
#写法一
goods:
price: 10
count: 20
#写法二
goods: {price: 10,count: 20}
数组(List、Set)
#写法一
color: [白色,黑色]
#写法二
color:
- 白色
- 黑色
如何将yaml转换成properties?或者是properties转换成yaml?
网上有许多工具
在线YAML转Properties工具:https://tooltt.com/yaml2properties/
port: 8081
goods:
price: 10
count: 20
color:
- 白色
- 黑色
port=8081
goods.price=10
goods.count=20
color[0]=白色
color[1]=黑色
在线Properties转YAML工具:https://www.toyaml.com/index.html
留言与评论(共有 0 条评论) “” |