The Hocon Configuration Format extends the Vert.x Configuration Retriever and provides the support for the HOCON(https://github.com/typesafehub/config/blob/master/HOCON.md) format.
It supports includes, json, properties, macros…
Using the Hocon Configuration Format
To use the Hocon Configuration Format, add the following dependency to the dependencies section of your build descriptor:
-
Maven (in your
pom.xml
):
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-config-hocon</artifactId>
<version>3.4.0.Beta1</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-config</artifactId>
<version>3.4.0.Beta1</version>
</dependency>
-
Gradle (in your
build.gradle
file):
compile 'io.vertx:vertx-config:3.4.0.Beta1'
compile 'io.vertx:vertx-config-hocon:3.4.0.Beta1'
Configuring the store to use HOCON
Once added to your classpath or dependencies, you need to configure the
ConfigRetriever
to use this format:
import io.vertx.config.ConfigRetriever
import io.vertx.config.ConfigRetrieverOptions
import io.vertx.config.ConfigStoreOptions
import io.vertx.kotlin.config.*
import io.vertx.kotlin.core.json.*
var store = ConfigStoreOptions(
type = "file",
config = json {
obj(
"path" to "my-config.yaml",
"format" to "yaml"
)
})
var retriever = ConfigRetriever.create(vertx, ConfigRetrieverOptions(
stores = listOf(store)))
You just need to set format
to hocon
.