spring - 为什么我们应该在属性上使用 yml

标签 spring properties yaml

如果我们把 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/

相关文章:

Spring HATEOAS 递归表示模型处理器?

Java-Spring 启动 : Access-Control- Allow-Origin not working

java - 如何共享 2 上下文的属性占位符

python - 如何动态创建 PyQt 属性

c# - 在 Click 事件中从 TextBox 中选择文本

json - 在 Google 容器中挂载 Google 存储桶

Ruby 1.9.2 补丁级别 180 - libyaml 破坏了 yaml 节点引用

java - 将 Spring Security 与 JPA 结合使用

javascript - 列出窗口对象的所有属性?

yaml - 为什么我收到 VpcId : expected type: String, 已找到 : JSONArray error with my CloudFormation Template?