Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should we use yml over properties

If we put spring.datasource.url = url it takes only one line.

However, If we put same thing in .yml it takes 4 lines.

spring : 
  datasource:
    url : url

Yet developers and frameworks(like Spring) prefer .yml over .properties.

Why should we use .yml over .properties file?

like image 702
Mehraj Malik Avatar asked Dec 31 '17 06:12

Mehraj Malik


1 Answers

Some Googling would have definitely helped you.

Ex : From 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.

and,

Properties file is mainly used with Java, supports only String types and is non-hierarchical; we can have maps by denoting hierarchies as dots

Another long and descriptive guide is http://hsoienterprises.com/2014/03/10/property-list-vs-json-vs-yaml/ , which I'll leave for you to read.

like image 167
Ishan Thilina Somasiri Avatar answered Oct 17 '22 05:10

Ishan Thilina Somasiri