如果我们把 spring.datasource.url = url
它只需要一行。
但是,如果我们把同样的东西放在 .yml
它需要 4 行。
spring :
datasource:
url : url
然而,开发人员和框架(如
Spring
)更喜欢 .yml
在 .properties
.为什么要使用
.yml
在 .properties
文件?
最佳答案
一些谷歌搜索肯定会帮助你。
例如:来自 http://javajee.com/a-quick-comparison-of-yaml-with-properties-file ,
YAML supports Maps, lists and scalar types. YAML is hierarchical and may use consistent spaces to denote hierarchy.
和,
Properties file is mainly used with Java, supports only String types and is non-hierarchical; we can have maps by denoting hierarchies as dots
另一个长而描述性的指南是 http://hsoienterprises.com/2014/03/10/property-list-vs-json-vs-yaml/ ,我会留给你阅读。
关于spring - 为什么我们应该在属性上使用 yml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48040554/