Death to yaml

A while back, spring started supporting yaml files as well as properties files for its configuration. Newer things sounded good so I switched to it.

My experience has been awful. Silent failures that don’t show errors and lead me down wild goose chases.

The problem is that yaml files are white-space sensitive. Indentation matters. And the indentation must be consistent: I you use 2-spaces somewhere and 3-spaces somewhere else, the indentation will not work and the parser will silently ignore the properties.

I must have had 20 of these errors. Sometimes I caught it quickly. Other times I spent an hour looking for the problem in code that wasn’t there. I’ve had enough. Back to boring properties files.

Note that we will often find yaml code on the internet that we want to use. For that, pick one of the yaml-to-properties online web pages.

Here is my last error that was the final straw:

The following is incorrect! Run this code and spring will throw a fatal error that it could not find the Datasource

spring:
 application:
  name: jsonstore-server
  main:
    banner-mode: OFF
  datasource:
    url: jdbc:postgresql://${postgres.url:localhost:5432/jsonstore}

This is correct! Can you spot the difference?

spring:
  application:
    name: jsonstore-server
  main:
    banner-mode: OFF
  datasource:
    url: jdbc:postgresql://${postgres.url:localhost:5432/jsonstore}

I rest my case.