Setting active profile and config location from command line in spring boot

There are two different ways you can add/override spring properties on the command line. Option 1: Java System Properties (VM Arguments) It’s important that the -D parameters are before your application.jar otherwise they are not recognized. java -jar -Dspring.profiles.active=prod application.jar Option 2: Program arguments java -jar application.jar –spring.profiles.active=prod –spring.config.location=c:\config

How to use YamlPropertiesFactoryBean to load YAML files using Spring Framework 4.1?

With XML config I’ve been using this construct: <context:annotation-config/> <bean id=”yamlProperties” class=”org.springframework.beans.factory.config.YamlPropertiesFactoryBean”> <property name=”resources” value=”classpath:test.yml”/> </bean> <context:property-placeholder properties-ref=”yamlProperties”/> Of course you have to have the snakeyaml dependency on your runtime classpath. I prefer XML config over the java config, but I recon it shouldn’t be hard to convert it. edit: java config for completeness sake … Read more

In Python, how can you load YAML mappings as OrderedDicts?

Python >= 3.6 In python 3.6+, it seems that dict loading order is preserved by default without special dictionary types. The default Dumper, on the other hand, sorts dictionaries by key. Starting with pyyaml 5.1, you can turn this off by passing sort_keys=False: a = dict(zip(“unsorted”, “unsorted”)) s = yaml.safe_dump(a, sort_keys=False) b = yaml.safe_load(s) assert … Read more

How to set multiple commands in one yaml file with Kubernetes?

command: [“/bin/sh”,”-c”] args: [“command one; command two && command three”] Explanation: The command [“/bin/sh”, “-c”] says “run a shell, and execute the following instructions”. The args are then passed as commands to the shell. In shell scripting a semicolon separates commands, and && conditionally runs the following command if the first succeed. In the above … Read more

YAML current date in rmarkdown

This is a little bit tricky, but you just need to make the date field valid in YAML by quoting the inline R expression, e.g. date: “`r format(Sys.time(), ‘%d %B, %Y’)`” Then the parsing error will be gone, and the date will be generated in the markdown output so Pandoc can use the value from … Read more

What is the difference between YAML and JSON?

Technically YAML is a superset of JSON. This means that, in theory at least, a YAML parser can understand JSON, but not necessarily the other way around. See the official specs, in the section entitled “YAML: Relation to JSON”. In general, there are certain things I like about YAML that are not available in JSON. … Read more