Engineering Full Stack Apps with Java and JavaScript
YAML is a human friendly data serialization standard, which is mainly made for configuration files. YAML stands for YAML Ain't Markup Language. YAML can be used with many programming languages.
YAML supports Maps, lists and scalar types. YAML is hierarchical and may use consistent spaces to denote hierarchy. It will also support inline maps. YAML also supports multiple Spring profiles in single YAML config file. One limitation of YAML however is that it does not work with @PropertySource annotation. Read more @ http://yaml.org/.
Example:
map1:
key: k
value: 9
map2: {b=true, date=2016-10-10}
Properties file is mainly used with Java, supports only String types and is non-hierarchical; we can have maps by denoting hierarchies as dots. Properties file will also work with @PropertySource annotation. One of the limitation of properties file is that we can only configure one Spring profile per properties file.
Example:
map1.key=k
map2.value=9
Lists may be represented using the array syntax or as inline list (separated by commas) in a properties file:
myList1[0] = one
myList1[1] = two
myList2 = one, two
Lists are represented hierarchically or as inline list in YAML:
myList1:
- one
- two
myList2: [one, two]
Properties files have “. properties” extension, whereas a YAML has a “. yml” or “. yaml” extension.
Comment syntaxes are same in both:
# this is a comment