This project, as the name entails, provides YAML configuration support for the DeltaSpike
configuration mechanism and uses snakeyaml to bind the properties to an implementation
of the MapConfigSource
.
The Gradle/Maven import strings can be found at the maven-central badge above!
The configuration should work out of the box once you've depended on it via Gradle or Maven.
It will automatically look for an application.yml
on the root of the classpath
and load it without any additional configuration.
If you want a custom file name, or load order, you can extend and override the
YamlConfigSource
class, and follow the instructions on the DeltaSpike documentation:
public class CustomYamlConfigSource extends YamlConfigSource {
public CustomYamlConfigSource() {
super("custom_application.yml", false);
}
}
There are two modes for the YamlConfigSource
, non-indexed (default) and indexed.
We'll discuss them both using the following YAML as an example.
application:
name: YAML4DeltaSpike
messages:
- source: source0
target: target0
- source: source1
target: target1
The non-indexed mode will convert the array of nested objects to a series of lists.
application.name=YAML4DeltaSpike
application.messages.source=source0,source1
application.messages.target=target0,target1
The indexed mode will convert the array of nested objects to the property key but with an index added, similarly to that of an array.
application.name=YAML4DeltaSpike
application.messages[0].source=source0
application.messages[0].target=target0
application.messages[1].source=source1
application.messages[1].target=target1
This project is open-source under the Apache 2.0!
While not legal advice, you can find a TL;DR that sums up what
you're allowed and not allowed to do along with any requirements if you want to
use or derive work from this source code!