Using MicroProfile Config to make configuration options available from a single API

The MicroProfile Config API enables application configuration properties from multiple sources to be amalgamated into a single set of configuration properties and accessed by using a single client API.

Open Liberty For the most recent information about using the Liberty MicroProfile Config, see the Open Liberty website and the Open Liberty MicroProfile Config guides.

Liberty applications can make full use of the MicroProfile Config API.

Default configuration values can be retrieved from Java™ System Properties, process environment variables, or configuration files of the form ${CLASSPATH}/META-INF/microprofile-config.properties. Users can register Java objects that implement a ConfigSource interface directly by using an API, or by way of the Java ServiceLoader pattern to programmatically provide configuration values, for example, to proxy for a database or remote configuration service.

Multiple configuration sources

Different sources of configuration properties can be given different priorities. Higher priority sources can then override property values from lower priority sources. This method allows for a library or application developer to package code with associated configuration settings that can then be overridden during application assembly, installation, or at run time in response to events.

A single configuration source can be used by multiple services with some properties that vary for a specific service type or instance. This enables applications to be composed dynamically from multiple services with minimum configuration work.

You can configure the server.xml file to use the mpConfig-1.3 feature instead of the mpConfig-1.2 or mpConfig-1.1 feature. For more information about mpConfig-1.3, see Enabling the MicroProfile Config API. The mpConfig-1.3 feature uses the MicroProfile Config 1.3 specification at https://github.com/eclipse/microprofile-config/releases/tag/1.3.

Dynamic properties

Configuration property values can be dynamic and changes in values are available to the application without a restart. Therefore, this allows for runtime changes to be picked up by the application, which enables dynamic services.

Injected configuration values

Configuration values can be directly injected into application code by using CDI without requiring user code to retrieve them. This method allows code to run unchanged under different configurations for development, test, or production environments.

Typed configuration objects

Users can register type Converter code to convert a String property to another type to allow properties to be retrieved or injected in a type safe manner.